[Numpy-svn] r8105 - branches/1.4.x/numpy/testing

numpy-svn@scip... numpy-svn@scip...
Tue Feb 9 02:59:54 CST 2010


Author: cdavid
Date: 2010-02-09 02:59:54 -0600 (Tue, 09 Feb 2010)
New Revision: 8105

Modified:
   branches/1.4.x/numpy/testing/utils.py
Log:
ENH: handle complex input for assert_array_almost_equal_nulp.

(cherry picked from commit 6078289d9c1e69c0b043e4bb2571caafb6b2910d)

Modified: branches/1.4.x/numpy/testing/utils.py
===================================================================
--- branches/1.4.x/numpy/testing/utils.py	2010-02-09 08:59:35 UTC (rev 8104)
+++ branches/1.4.x/numpy/testing/utils.py	2010-02-09 08:59:54 UTC (rev 8105)
@@ -1108,9 +1108,12 @@
     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



More information about the Numpy-svn mailing list