Docs/Numerical Arrays (NumPy)/np.testing.assert_allclose
Back to Numerical Arrays (NumPy)

np.testing.assert_allclose

Assert that two arrays are element-wise equal within tolerance.

Syntax

np.testing.assert_allclose(actual, desired, rtol?, atol?, equal_nan?, err_msg?, _verbose?)

Description

Assert that two arrays are element-wise equal within tolerance. The comparison is: |actual - desired| <= atol + rtol * |desired| This is the recommended assertion for floating-point comparisons.

Parameters

NameDescription
actual- Actual array
desired- Expected array
rtol(optional)- Relative tolerance (default: 1e-7)
atol(optional)- Absolute tolerance (default: 0)
equal_nan(optional)- If true, NaN == NaN (default: true)
err_msg(optional)- Custom error message
_verbose(optional)boolean

Returns

void