diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-02-19 10:01:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 10:01:59 +0200 |
commit | 760800d2c602b1c4e1a10d3a0ba12944df28cc73 (patch) | |
tree | 678681e478dc0973bda53e8d5379510d25e83e91 /numpy/testing/_private/utils.py | |
parent | df40e550d442e910826e4817d38cebb902f48d77 (diff) | |
parent | ce86ca5589469f4382f9c66b6464668855984b4c (diff) | |
download | numpy-760800d2c602b1c4e1a10d3a0ba12944df28cc73.tar.gz |
Merge pull request #15598 from r-devulap/ignore-differences-nan
BUG: Ignore differences in NAN for computing ULP differences, remove non-AVX tests
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r-- | numpy/testing/_private/utils.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 67b7d317c..bf0892a29 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1609,6 +1609,12 @@ def assert_array_max_ulp(a, b, maxulp=1, dtype=None): AssertionError If one or more elements differ by more than `maxulp`. + Notes + ----- + For computing the ULP difference, this API does not differentiate between + various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000 + is zero. + See Also -------- assert_array_almost_equal_nulp : Compare two arrays relatively to their @@ -1649,6 +1655,12 @@ def nulp_diff(x, y, dtype=None): number of representable floating point numbers between each item in x and y. + Notes + ----- + For computing the ULP difference, this API does not differentiate between + various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000 + is zero. + Examples -------- # By definition, epsilon is the smallest number such as 1 + eps != 1, so @@ -1668,8 +1680,11 @@ def nulp_diff(x, y, dtype=None): if np.iscomplexobj(x) or np.iscomplexobj(y): raise NotImplementedError("_nulp not implemented for complex array") - x = np.array(x, dtype=t) - y = np.array(y, dtype=t) + x = np.array([x], dtype=t) + y = np.array([y], dtype=t) + + x[np.isnan(x)] = np.nan + y[np.isnan(y)] = np.nan if not x.shape == y.shape: raise ValueError("x and y do not have the same shape: %s - %s" % |