[Numpy-svn] r8310 - trunk/numpy/core/tests

numpy-svn@scip... numpy-svn@scip...
Tue Mar 30 22:45:06 CDT 2010


Author: cdavid
Date: 2010-03-30 22:45:06 -0500 (Tue, 30 Mar 2010)
New Revision: 8310

Modified:
   trunk/numpy/core/tests/test_regression.py
   trunk/numpy/core/tests/test_umath.py
Log:
BUG: fix divide by zero warnings in tests.

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2010-03-31 02:33:13 UTC (rev 8309)
+++ trunk/numpy/core/tests/test_regression.py	2010-03-31 03:45:06 UTC (rev 8310)
@@ -1047,15 +1047,19 @@
 
     def test_errobj_reference_leak(self, level=rlevel):
         """Ticket #955"""
-        z = int(0)
-        p = np.int32(-1)
+        old_err = np.seterr(all="ignore")
+        try:
+            z = int(0)
+            p = np.int32(-1)
 
-        gc.collect()
-        n_before = len(gc.get_objects())
-        z**p  # this shouldn't leak a reference to errobj
-        gc.collect()
-        n_after = len(gc.get_objects())
-        assert n_before >= n_after, (n_before, n_after)
+            gc.collect()
+            n_before = len(gc.get_objects())
+            z**p  # this shouldn't leak a reference to errobj
+            gc.collect()
+            n_after = len(gc.get_objects())
+            assert n_before >= n_after, (n_before, n_after)
+        finally:
+            np.seterr(**old_err)
 
     def test_void_scalar_with_titles(self, level=rlevel):
         """No ticket"""
@@ -1253,8 +1257,12 @@
             min = np.array([np.iinfo(t).min])
             min /= -1
 
-        for t in (np.int8, np.int16, np.int32, np.int64, np.int, np.long):
-            test_type(t)
+        old_err = np.seterr(divide="ignore")
+        try:
+            for t in (np.int8, np.int16, np.int32, np.int64, np.int, np.long):
+                test_type(t)
+        finally:
+            np.seterr(**old_err)
 
     def test_buffer_hashlib(self):
         try:

Modified: trunk/numpy/core/tests/test_umath.py
===================================================================
--- trunk/numpy/core/tests/test_umath.py	2010-03-31 02:33:13 UTC (rev 8309)
+++ trunk/numpy/core/tests/test_umath.py	2010-03-31 03:45:06 UTC (rev 8310)
@@ -863,8 +863,12 @@
 
 def test_copysign():
     assert np.copysign(1, -1) == -1
-    assert 1 / np.copysign(0, -1) < 0
-    assert 1 / np.copysign(0, 1) > 0
+    old_err = np.seterr(divide="ignore")
+    try:
+        assert 1 / np.copysign(0, -1) < 0
+        assert 1 / np.copysign(0, 1) > 0
+    finally:
+        np.seterr(**old_err)
     assert np.signbit(np.copysign(np.nan, -1))
     assert not np.signbit(np.copysign(np.nan, 1))
 



More information about the Numpy-svn mailing list