allclose¶
- astropy.units.quantity.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, bnumpy:array_like or
Quantity
Input values or arrays to compare
- rtolnumpy:array_like or
Quantity
The relative tolerance for the comparison, which defaults to
1e-5
. Ifrtol
is aQuantity
, then it must be dimensionless.- atolnumber or
Quantity
The absolute tolerance for the comparison. The units (or lack thereof) of
a
,b
, andatol
must be consistent with each other. IfNone
,atol
defaults to zero in the appropriate units.- equal_nan
bool
Whether to compare NaN’s as equal. If
True
, NaNs ina
will be considered equal to NaN’s inb
.
- a, bnumpy:array_like or
- Raises:
UnitsError
If the dimensions of
a
,b
, oratol
are incompatible, or ifrtol
is not dimensionless.
See also
Notes
This is a
Quantity
-aware version ofnumpy.allclose()
. However, this differs from thenumpy
function in that the default for the absolute tolerance here is zero instead ofatol=1e-8
innumpy
, as there is no natural way to set a default absolute tolerance given two inputs that may have differently scaled units.