summaryrefslogtreecommitdiff
path: root/numpy/testing/tests
diff options
context:
space:
mode:
authorMark Harfouche <mark.harfouche@gmail.com>2022-06-29 20:05:19 -0400
committerMark Harfouche <mark.harfouche@gmail.com>2022-06-29 22:59:48 -0400
commit57d04d883e874c611091933c4c36e1cd43ea0e04 (patch)
tree6a1474dce1b2386238b1d3a42204cb5f567c7f42 /numpy/testing/tests
parentd592523b5a7482e3486fc1bb694b9c570be30365 (diff)
downloadnumpy-57d04d883e874c611091933c4c36e1cd43ea0e04.tar.gz
TST: Add a failing test case to demonstrate the bug gh2176
Diffstat (limited to 'numpy/testing/tests')
-rw-r--r--numpy/testing/tests/test_utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index 49eeecc8e..da3c4f80b 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -916,6 +916,20 @@ class TestAssertAllclose:
a = np.array([[1, 2, 3, "NaT"]], dtype="m8[ns]")
assert_allclose(a, a)
+ def test_error_message_unsigned(self):
+ """Check the the message is formatted correctly when overflow can occur
+ (gh21768)"""
+ # Ensure to test for potential overflow in the case of:
+ # x - y
+ # and
+ # y - x
+ x = np.asarray([0, 1, 8], dtype='uint8')
+ y = np.asarray([4, 4, 4], dtype='uint8')
+ with pytest.raises(AssertionError) as exc_info:
+ assert_allclose(x, y, atol=3)
+ msgs = str(exc_info.value).split('\n')
+ assert_equal(msgs[4], 'Max absolute difference: 4')
+
class TestArrayAlmostEqualNulp: