From a16fc9499eaa7cc9d7532f8a51725c6ed647cd1b Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Tue, 1 Jan 2019 22:50:29 -0800 Subject: 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. --- tools/refguide_check.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/refguide_check.py b/tools/refguide_check.py index 3d885e37f..fec715f63 100644 --- a/tools/refguide_check.py +++ b/tools/refguide_check.py @@ -76,6 +76,7 @@ PUBLIC_SUBMODULES = [ 'polynomial', 'matrixlib', 'random', + 'testing', ] # Docs for these modules are included in the parent module -- cgit v1.2.1