summaryrefslogtreecommitdiff
path: root/numpy/testing/tests
diff options
context:
space:
mode:
authorCakeWithSteak <37267737+CakeWithSteak@users.noreply.github.com>2019-09-05 16:20:13 +0200
committerSebastian Berg <sebastian@sipsolutions.net>2019-09-05 09:20:13 -0500
commit3dccd841476d26b5807156b904b55c04c6a3d370 (patch)
tree13e25978aad375ff80e3c499e250d43af640b0dc /numpy/testing/tests
parent6bdbc1e2fd20df7272802df88f3790e5dd7ed057 (diff)
downloadnumpy-3dccd841476d26b5807156b904b55c04c6a3d370.tar.gz
BUG: Fixed maximum relative error reporting in assert_allclose (gh-13802)
Fixed maximum relative error reporting in assert_allclose: In cases where the two arrays have zeros at the same positions it will no longer report nan as the max relative error
Diffstat (limited to 'numpy/testing/tests')
-rw-r--r--numpy/testing/tests/test_utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index 4f1b46d4f..688bedc16 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -881,6 +881,15 @@ class TestAssertAllclose(object):
assert_array_less(a, b)
assert_allclose(a, b)
+ def test_report_max_relative_error(self):
+ a = np.array([0, 1])
+ b = np.array([0, 2])
+
+ with pytest.raises(AssertionError) as exc_info:
+ assert_allclose(a, b)
+ msg = str(exc_info.value)
+ assert_('Max relative difference: 0.5' in msg)
+
class TestArrayAlmostEqualNulp(object):