- lsst.utils.tests.assertFloatsAlmostEqual(testCase: TestCase, lhs: float | ndarray, rhs: float | ndarray, rtol: float | None = 2.220446049250313e-16, atol: float | None = 2.220446049250313e-16, relTo: float | None = None, printFailures: bool = True, plotOnFailure: bool = False, plotFileName: str | None = None, invert: bool = False, msg: str | None = None, ignoreNaNs: bool = False) None ¶
Highly-configurable floating point comparisons for scalars and arrays.
The test assertion will fail if all elements
rhsare not equal to within the tolerances specified by
atol. More precisely, the comparison is:
abs(lhs - rhs) <= relTo*rtol OR abs(lhs - rhs) <= atol
None, that term in the comparison is not performed at all.
When not specified,
relTois the elementwise maximum of the absolute values of
rhs. If set manually, it should usually be set to either
rhs, or a scalar value typical of what is expected.
Instance the test is part of.
- lhsscalar or array-like
LHS value(s) to compare; may be a scalar or array-like of any dimension.
- rhsscalar or array-like
RHS value(s) to compare; may be a scalar or array-like of any dimension.
Relative tolerance for comparison; defaults to double-precision epsilon.
Absolute tolerance for comparison; defaults to double-precision epsilon.
Value to which comparison with rtol is relative.
Upon failure, print all inequal elements as part of the message.
Upon failure, plot the originals and their residual with matplotlib. Only 2-d arrays are supported.
Filename to save the plot to. If
None, the plot will be displayed in a window.
String to append to the error message when assert fails.
Falseis 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 when
invert=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.
The values are not almost equal.