assertFloatsAlmostEqual¶

lsst.utils.tests.
assertFloatsAlmostEqual
(testCase: unittest.case.TestCase, lhs: Union[float, numpy.ndarray], rhs: Union[float, numpy.ndarray], rtol: Optional[float, None] = 2.220446049250313e16, atol: Optional[float, None] = 2.220446049250313e16, relTo: Optional[float, None] = None, printFailures: bool = True, plotOnFailure: bool = False, plotFileName: Optional[str, None] = None, invert: bool = False, msg: Optional[str, None] = None, ignoreNaNs: bool = False) → None¶ Highlyconfigurable floating point comparisons for scalars and arrays.
The test assertion will fail if all elements
lhs
andrhs
are not equal to within the tolerances specified byrtol
andatol
. More precisely, the comparison is:abs(lhs  rhs) <= relTo*rtol OR abs(lhs  rhs) <= atol
If
rtol
oratol
isNone
, that term in the comparison is not performed at all.When not specified,
relTo
is the elementwise maximum of the absolute values oflhs
andrhs
. If set manually, it should usually be set to eitherlhs
orrhs
, or a scalar value typical of what is expected.Parameters:  testCase :
unittest.TestCase
Instance the test is part of.
 lhs : scalar or arraylike
LHS value(s) to compare; may be a scalar or arraylike of any dimension.
 rhs : scalar or arraylike
RHS value(s) to compare; may be a scalar or arraylike of any dimension.
 rtol :
float
, optional Relative tolerance for comparison; defaults to doubleprecision epsilon.
 atol :
float
, optional Absolute tolerance for comparison; defaults to doubleprecision epsilon.
 relTo :
float
, optional Value to which comparison with rtol is relative.
 printFailures :
bool
, optional Upon failure, print all inequal elements as part of the message.
 plotOnFailure :
bool
, optional Upon failure, plot the originals and their residual with matplotlib. Only 2d arrays are supported.
 plotFileName :
str
, optional Filename to save the plot to. If
None
, the plot will be displayed in a window. invert :
bool
, optional If
True
, invert the comparison and fail only if any elements are equal. Used to implementassertFloatsNotEqual
, which should generally be used instead for clarity. will returnTrue
). msg :
str
, optional String to append to the error message when assert fails.
 ignoreNaNs :
bool
, optional If
True
(False
is default) mask out any NaNs from operand arrays before performing comparisons if they are in the same locations; NaNs in different locations are trigger test assertion failures, even wheninvert=True
. Scalar NaNs are treated like arrays containing only NaNs of the same shape as the other operand, and no comparisons are performed if both sides are scalar NaNs.
Raises:  AssertionError
The values are not almost equal.
 testCase :