[Numpy-svn] r8678 - trunk/numpy/lib/tests

numpy-svn@scip... numpy-svn@scip...
Tue Aug 31 09:02:59 CDT 2010


Author: dhuard
Date: 2010-08-31 09:02:59 -0500 (Tue, 31 Aug 2010)
New Revision: 8678

Modified:
   trunk/numpy/lib/tests/test_arraysetops.py
   trunk/numpy/lib/tests/test_function_base.py
Log:
Made sure the warning filters in test_function_base and test_arraysetops do not modify user defined filters.

Modified: trunk/numpy/lib/tests/test_arraysetops.py
===================================================================
--- trunk/numpy/lib/tests/test_arraysetops.py	2010-08-31 12:33:02 UTC (rev 8677)
+++ trunk/numpy/lib/tests/test_arraysetops.py	2010-08-31 14:02:59 UTC (rev 8678)
@@ -16,18 +16,16 @@
         c = unique( a )
         assert_array_equal( c, ec )
 
-        warnings.simplefilter('ignore', Warning)
         vals, indices = unique( a, return_index=True )
-        warnings.resetwarnings()
+        
 
         ed = np.array( [2, 3, 0, 1] )
         assert_array_equal(vals, ec)
         assert_array_equal(indices, ed)
 
-        warnings.simplefilter('ignore', Warning)
         vals, ind0, ind1 = unique( a, return_index=True,
                                      return_inverse=True )
-        warnings.resetwarnings()
+        
 
         ee = np.array( [2, 3, 0, 1, 0, 2, 3] )
         assert_array_equal(vals, ec)
@@ -61,13 +59,15 @@
         b = np.array( [2, 1, 4, 3, 3, 1, 5] )
 
         ec = np.array( [1, 2, 5] )
-        warnings.simplefilter('ignore', Warning)
-        c = intersect1d_nu( a, b )
-        warnings.resetwarnings()
+        warnings.filterwarnings('ignore', message='\s*`intersect1d_nu` is deprecated!')
+        warnings.filterwarnings('ignore', message='\s*`unique1d` is deprecated!')
+        c = intersect1d_nu( a, b )        
         assert_array_equal( c, ec )
-
         assert_array_equal([], intersect1d_nu([],[]))
+        warnings.filters.pop(0)
+        warnings.filters.pop(0)
 
+
     def test_setxor1d( self ):
         a = np.array( [5, 7, 1, 2] )
         b = np.array( [2, 4, 3, 1, 5] )
@@ -110,9 +110,9 @@
         b = np.array( [2, 4, 3, 1, 5] )
 
         ec = np.array( [True, False, True, True] )
-        warnings.simplefilter('ignore', Warning)
+        warnings.filterwarnings('ignore', '\s*`setmember1d` is deprecated!')
         c = setmember1d( a, b )
-        warnings.resetwarnings()
+        
         assert_array_equal( c, ec )
 
         a[0] = 8
@@ -126,6 +126,7 @@
         assert_array_equal( c, ec )
 
         assert_array_equal([], setmember1d([],[]))
+        warnings.filters.pop(0)
 
     def test_in1d(self):
         a = np.array( [5, 7, 1, 2] )

Modified: trunk/numpy/lib/tests/test_function_base.py
===================================================================
--- trunk/numpy/lib/tests/test_function_base.py	2010-08-31 12:33:02 UTC (rev 8677)
+++ trunk/numpy/lib/tests/test_function_base.py	2010-08-31 14:02:59 UTC (rev 8678)
@@ -565,7 +565,8 @@
         area = sum(a * diff(b))
         assert_almost_equal(area, 1)
 
-        warnings.simplefilter('ignore', Warning)
+        warnings.filterwarnings('ignore', 
+            message="\s*This release of NumPy fixes a normalization bug")
         # Check with non-constant bin widths
         v = np.arange(10)
         bins = [0,1,3,6,10]
@@ -584,7 +585,7 @@
         # mailing list Aug. 6, 2010. 
         counts, dmy = np.histogram([1,2,3,4], [0.5,1.5,np.inf], normed=True)
         assert_equal(counts, [.25, 0])
-        warnings.resetwarnings()
+        warnings.filters.pop(0)
         
     def test_outliers(self):
         # Check that outliers are not tallied
@@ -647,12 +648,14 @@
         wa, wb = histogram([1, 2, 2, 4], bins=4, weights=[4, 3, 2, 1], normed=True)
         assert_array_almost_equal(wa, array([4, 5, 0, 1]) / 10. / 3. * 4)
 
-        warnings.simplefilter('ignore', Warning)
+        warnings.filterwarnings('ignore', \
+            message="\s*This release of NumPy fixes a normalization bug")
         # Check weights with non-uniform bin widths
         a,b = histogram(np.arange(9), [0,1,3,6,10], \
                         weights=[2,1,1,1,1,1,1,1,1], normed=True)
         assert_almost_equal(a, [.2, .1, .1, .075])
-        warnings.resetwarnings()
+        warnings.filters.pop(0)
+        
 
 class TestHistogramdd(TestCase):
     def test_simple(self):



More information about the Numpy-svn mailing list