assert_values_equal#

lsst.images.tests.assert_values_equal(a, b, *, rtol=0.0, atol=0.0, equal_nan=True, label='', wrap_angles=False)#

Assert that two arrays, quantities, floats, astropy times, or sky coordinates are equal or close.

On mismatch this raises an AssertionError with a concise report (count, max absolute difference, location, NaN-mismatch count) rather than dumping the arrays. Exact (non-floating-point) mismatches instead report through numpy.testing.assert_array_equal.

Both operands must be of the same kind: both floating-point numeric (bare or as Quantity or TimeDelta), or both the same astropy type (Time or astropy.coordinates.SkyCoord). Operands that cannot hold floating-point values (integers, bools, strings) are compared exactly, with no tolerance or NaN semantics. Tolerances never have their units guessed: a bare-float atol is only valid for dimensionless operands, and for unitful operands only exactly 0.0 (which is unit-independent) is accepted without units.

Parameters:
  • a (ndarray | Quantity | float | Time | TimeDelta | SkyCoord) – First value to compare.

  • b (ndarray | Quantity | float | Time | TimeDelta | SkyCoord) – Second value to compare.

  • rtol (float, default: 0.0) – Relative tolerance, applied to the operand magnitudes. Must be zero for comparisons of separations.

  • atol (float | Quantity | TimeDelta, default: 0.0) – Absolute tolerance. For dimensionless operands, a bare float. For unitful operands, a Quantity with units compatible with a, or exactly 0.0.

  • equal_nan (bool, default: True) – If True, treat NaN as equal to NaN. A astropy.coordinates.SkyCoord element counts as NaN only when both of its coordinates are NaN.

  • label (str, default: '') – Prefix prepended to the failure message.

  • wrap_angles (bool, default: False) – If True, compare a and b (angular quantities) modulo 2 pi.

Return type:

None

This page was last modified on .