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

Whether two arrays are element-wise equal within a tolerance.

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.


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


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

See also



This is a Quantity-aware version of numpy.allclose(). 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.