diff options
author | David Cournapeau <cournape@gmail.com> | 2010-02-09 08:40:36 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2010-02-09 08:40:36 +0000 |
commit | 2f7b48c59f0998e053e108d57cde42d8778bef82 (patch) | |
tree | f248b893dd3038f2e7a4540a61efa04dfa4317f0 /numpy/testing/utils.py | |
parent | 3e5a12cb388e5d9a0b8dba3d1ebf4c55bf419272 (diff) | |
download | numpy-2f7b48c59f0998e053e108d57cde42d8778bef82.tar.gz |
ENH: handle complex input for assert_array_almost_equal_nulp.
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r-- | numpy/testing/utils.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 012313618..b22573965 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -1104,9 +1104,12 @@ def assert_array_almost_equal_nulp(x, y, nulp=1): ay = np.abs(y) ref = nulp * np.spacing(np.where(ax > ay, ax, ay)) if not np.all(np.abs(x-y) <= ref): - max_nulp = np.max(nulp_diff(x, y)) - raise AssertionError("X and Y are not equal to %d ULP "\ - "(max is %g)" % (nulp, max_nulp)) + if np.iscomplexobj(x) or np.iscomplexobj(y): + msg = "X and Y are not equal to %d ULP" % nulp + else: + max_nulp = np.max(nulp_diff(x, y)) + msg = "X and Y are not equal to %d ULP (max is %g)" % (nulp, max_nulp) + raise AssertionError(msg) def assert_array_max_ulp(a, b, maxulp=1, dtype=None): """Given two arrays a and b, check that every item differs in at most N |