You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If two different arrays share a zero at the same position the max relative difference will be reported as NaN by assert_allclose. This is because in assert_array_compare the error is simply calculated as max_rel_error = (error / abs(y)).max() which can result in 0/0 = NaN.
This hides the actual biggest relative difference and makes it more difficult to solve the problem in your code that is triggering the assertion.
Reproducing code example:
importnumpyasnpx=np.array([0, 1])
y=np.array([0, 2])
np.testing.assert_allclose(x, y, rtol=0.001)
Output:
AssertionError:
Not equal to tolerance rtol=0.001, atol=0
Mismatch: 50%
Max absolute difference: 1
Max relative difference: nan
x: array([0, 1])
y: array([0, 2])
Expected output:
AssertionError:
Not equal to tolerance rtol=0.001, atol=0
Mismatch: 50%
Max absolute difference: 1
Max relative difference: 0.5
x: array([0, 1])
y: array([0, 2])
Numpy/Python version information:
1.16.4
The text was updated successfully, but these errors were encountered:
If two different arrays share a zero at the same position the max relative difference will be reported as NaN by
assert_allclose
. This is because inassert_array_compare
the error is simply calculated asmax_rel_error = (error / abs(y)).max()
which can result in 0/0 = NaN.This hides the actual biggest relative difference and makes it more difficult to solve the problem in your code that is triggering the assertion.
Reproducing code example:
Output:
Expected output:
Numpy/Python version information:
1.16.4
The text was updated successfully, but these errors were encountered: