summaryrefslogtreecommitdiff
path: root/numpy/testing/_private/utils.py
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/_private/utils.py
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/_private/utils.py')
-rw-r--r--numpy/testing/_private/utils.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py
index 4957ef6d7..c553658cb 100644
--- a/numpy/testing/_private/utils.py
+++ b/numpy/testing/_private/utils.py
@@ -828,6 +828,9 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='',
# ignore errors for non-numeric types
with contextlib.suppress(TypeError):
error = abs(x - y)
+ if np.issubdtype(x.dtype, np.unsignedinteger):
+ error2 = abs(y - x)
+ np.minimum(error, error2, out=error)
max_abs_error = max(error)
if getattr(error, 'dtype', object_) == object_:
remarks.append('Max absolute difference: '