From 2f7b48c59f0998e053e108d57cde42d8778bef82 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Tue, 9 Feb 2010 08:40:36 +0000 Subject: ENH: handle complex input for assert_array_almost_equal_nulp. --- numpy/testing/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'numpy/testing') 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 -- cgit v1.2.1