allclose

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

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

Parameters
a, barray_like or Quantity

Input values or arrays to compare

rtolarray_like or dimensionless 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

isclose

Notes

This is a Quantity-aware version of numpy.allclose().