diff options
author | Stephan Hoyer <shoyer@gmail.com> | 2019-01-01 22:50:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-01 22:50:29 -0800 |
commit | a16fc9499eaa7cc9d7532f8a51725c6ed647cd1b (patch) | |
tree | b9df23e3024937390d00135616379fc266722339 /numpy/lib/function_base.py | |
parent | 43298265ab35b82e29ff772c466872a78531fabd (diff) | |
download | numpy-a16fc9499eaa7cc9d7532f8a51725c6ed647cd1b.tar.gz |
ENH: add "max difference" messages to np.testing.assert_array_equal (#12591)
Example behavior:
>>> x = np.array([1, 2, 3])
>>> y = np.array([1, 2, 3.0001])
>>> np.testing.assert_allclose(x, y)
AssertionError:
Not equal to tolerance rtol=1e-07, atol=0
Mismatch: 33.3%
Max absolute difference: 0.0001
Max relative difference: 3.33322223e-05
x: array([1, 2, 3])
y: array([1. , 2. , 3.0001])
Motivation: when writing numerical algorithms, I frequently find myself
experimenting to pick the right value of `atol` and `rtol` for
`np.testing.assert_allclose()`. If I make the tolerance too generous, I risk
missing regressions in accuracy, so I usually try to pick the smallest values
for which tests pass. This change immediately reveals appropriate values to
use for these parameters, so I don't need to guess and check.
Diffstat (limited to 'numpy/lib/function_base.py')
0 files changed, 0 insertions, 0 deletions