[Numpy-svn] r8245 - in trunk/numpy: core/tests testing

numpy-svn at scipy.org numpy-svn at scipy.org
Sun Feb 21 11:16:40 EST 2010


Author: charris
Date: 2010-02-21 10:16:40 -0600 (Sun, 21 Feb 2010)
New Revision: 8245

Modified:
   trunk/numpy/core/tests/test_umath.py
   trunk/numpy/testing/utils.py
Log:
BUG: More workarounds for np.isinf warning in tests.

Modified: trunk/numpy/core/tests/test_umath.py
===================================================================
--- trunk/numpy/core/tests/test_umath.py	2010-02-21 16:16:34 UTC (rev 8244)
+++ trunk/numpy/core/tests/test_umath.py	2010-02-21 16:16:40 UTC (rev 8245)
@@ -232,7 +232,11 @@
         np.seterr(**err)
 
 def assert_hypot_isinf(x, y):
-    assert np.isinf(ncu.hypot(x, y)), "hypot(%s, %s) is %s, not inf" % (x, y, ncu.hypot(x, y))
+    err = np.seterr(invalid='ignore')
+    try:
+        assert np.isinf(ncu.hypot(x, y)), "hypot(%s, %s) is %s, not inf" % (x, y, ncu.hypot(x, y))
+    finally:
+        np.seterr(**err)
 
 class TestHypotSpecialValues(TestCase):
     def test_nan_outputs(self):

Modified: trunk/numpy/testing/utils.py
===================================================================
--- trunk/numpy/testing/utils.py	2010-02-21 16:16:34 UTC (rev 8244)
+++ trunk/numpy/testing/utils.py	2010-02-21 16:16:40 UTC (rev 8245)
@@ -61,10 +61,14 @@
     exception is always raised.
 
     This should be removed once this problem is solved at the Ufunc level."""
-    from numpy.core import isfinite
-    st = isfinite(x)
-    if isinstance(st, types.NotImplementedType):
-        raise TypeError("isfinite not supported for this type")
+    from numpy.core import isfinite, seterr
+    err = seterr(invalid='ignore')
+    try:
+        st = isfinite(x)
+        if isinstance(st, types.NotImplementedType):
+            raise TypeError("isfinite not supported for this type")
+    finally:
+        seterr(**err)
     return st
 
 def gisinf(x):
@@ -78,10 +82,14 @@
     exception is always raised.
 
     This should be removed once this problem is solved at the Ufunc level."""
-    from numpy.core import isinf
-    st = isinf(x)
-    if isinstance(st, types.NotImplementedType):
-        raise TypeError("isinf not supported for this type")
+    from numpy.core import isinf, seterr
+    err = seterr(invalid='ignore')
+    try:
+        st = isinf(x)
+        if isinstance(st, types.NotImplementedType):
+            raise TypeError("isinf not supported for this type")
+    finally:
+        seterr(**err)
     return st
 
 def rand(*args):




More information about the Numpy-svn mailing list