testing.
assert_allclose
Raises an AssertionError if two objects are not equal up to desired tolerance.
The test is equivalent to allclose(actual, desired, rtol, atol) (note that allclose has different default values). It compares the difference between actual and desired to atol + rtol * abs(desired).
allclose(actual, desired, rtol, atol)
allclose
atol + rtol * abs(desired)
New in version 1.5.0.
Array obtained.
Array desired.
Relative tolerance.
Absolute tolerance.
If True, NaNs will compare equal.
The error message to be printed in case of failure.
If True, the conflicting values are appended to the error message.
If actual and desired are not equal up to specified precision.
See also
assert_array_almost_equal_nulp
assert_array_max_ulp
Examples
>>> x = [1e-5, 1e-3, 1e-1] >>> y = np.arccos(np.cos(x)) >>> np.testing.assert_allclose(x, y, rtol=1e-5, atol=0)