From 162b63b4ee2f9567c638699a92fc8477e281c924 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Sat, 18 Jun 2022 22:31:09 -0400 Subject: BUG: Ensure that assertion of unsigned dtypes does not return results that wrapped around. --- numpy/testing/_private/utils.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'numpy/testing/_private/utils.py') diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index e4f8b9892..b6afdd149 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -814,6 +814,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: ' -- cgit v1.2.1