summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2010-02-09 08:59:54 +0000
committerDavid Cournapeau <cournape@gmail.com>2010-02-09 08:59:54 +0000
commitc65c5878e93ce987b568d800198982ab9a63c7b5 (patch)
treef6d18f82522bfc56ff14bbc74a5810352fcbb72f
parent31397bdc0d22bafc803c66d98025e9ece8091412 (diff)
downloadnumpy-c65c5878e93ce987b568d800198982ab9a63c7b5.tar.gz
ENH: handle complex input for assert_array_almost_equal_nulp.
(cherry picked from commit 6078289d9c1e69c0b043e4bb2571caafb6b2910d)
-rw-r--r--numpy/testing/utils.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index c10754aa1..96b207e36 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -1108,9 +1108,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