isclose#

astropy.units.quantity.isclose(a, b, rtol=1e-05, atol=None, equal_nan=False)[source]#

Return a boolean array where two arrays are element-wise equal within a tolerance.

Parameters:
a, barray_like or Quantity

Input values or arrays to compare

rtolarray_like or Quantity

The relative tolerance for the comparison, which defaults to 1e-5. If rtol is a Quantity, then it must be dimensionless.

atolnumber or Quantity

The absolute tolerance for the comparison. The units (or lack thereof) of a, b, and atol must be consistent with each other. If None, atol defaults to zero in the appropriate units.

equal_nanbool

Whether to compare NaN’s as equal. If True, NaNs in a will be considered equal to NaN’s in b.

Raises:
UnitsError

If the dimensions of a, b, or atol are incompatible, or if rtol is not dimensionless.

See also

allclose

Notes

This is a Quantity-aware version of numpy.isclose(). However, this differs from the numpy function in that the default for the absolute tolerance here is zero instead of atol=1e-8 in numpy, as there is no natural way to set a default absolute tolerance given two inputs that may have differently scaled units.