allclose#
- astropy.units.quantity.allclose(a, b, rtol=1e-05, atol=None, equal_nan=False) 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
Quantity The relative tolerance for the comparison, which defaults to
1e-5. Ifrtolis aQuantity, then it must be dimensionless.- atolnumber or
Quantity The absolute tolerance for the comparison. The units (or lack thereof) of
a,b, andatolmust be consistent with each other. IfNone,atoldefaults to zero in the appropriate units.- equal_nan
bool Whether to compare NaN’s as equal. If
True, NaNs inawill be considered equal to NaN’s inb.
- a, barray_like or
- Raises:
UnitsErrorIf the dimensions of
a,b, oratolare incompatible, or ifrtolis not dimensionless.
See also
Notes
This is a
Quantity-aware version ofnumpy.allclose(). However, this differs from thenumpyfunction in that the default for the absolute tolerance here is zero instead ofatol=1e-8innumpy, as there is no natural way to set a default absolute tolerance given two inputs that may have differently scaled units.