summaryrefslogtreecommitdiff
path: root/numpy/testing/tests
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-07-06 19:04:18 -0700
committerGitHub <noreply@github.com>2022-07-06 19:04:18 -0700
commit43b666c9296b24bc072f13e43dd2c605b6e659d2 (patch)
tree2d3c3c1ea58099fc2dfb805dca901fdbb79ef610 /numpy/testing/tests
parentda6297b9f799301a109f478f9056dc9f5b7c6d27 (diff)
parent162b63b4ee2f9567c638699a92fc8477e281c924 (diff)
downloadnumpy-43b666c9296b24bc072f13e43dd2c605b6e659d2.tar.gz
Merge pull request #21795 from hmaarrfk/no_overflow_unsigned
ENH: Ensure that assertion of unsigned dtypes does not return results
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 c82343f0c..377f570bd 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -953,6 +953,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: