[Numpy-svn] r8334 - in trunk/numpy/lib: . tests

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Apr 14 13:24:50 EDT 2010


Author: charris
Date: 2010-04-14 12:24:50 -0500 (Wed, 14 Apr 2010)
New Revision: 8334

Modified:
   trunk/numpy/lib/tests/test_ufunclike.py
   trunk/numpy/lib/ufunclike.py
Log:
BUG: Use deprecated decorator in testing ufunclike.log2.

Modified: trunk/numpy/lib/tests/test_ufunclike.py
===================================================================
--- trunk/numpy/lib/tests/test_ufunclike.py	2010-04-14 17:17:53 UTC (rev 8333)
+++ trunk/numpy/lib/tests/test_ufunclike.py	2010-04-14 17:24:50 UTC (rev 8334)
@@ -1,7 +1,7 @@
 from numpy.testing import *
 import numpy.core as nx
 import numpy.lib.ufunclike as ufl
-import warnings
+from numpy.testing.decorators import deprecated
 
 class TestUfunclike(TestCase):
 
@@ -27,19 +27,16 @@
         assert_equal(res, tgt)
         assert_equal(out, tgt)
 
+    @deprecated()
     def test_log2(self):
         a = nx.array([4.5, 2.3, 6.5])
         out = nx.zeros(a.shape, float)
         tgt = nx.array([2.169925, 1.20163386, 2.70043972])
-        try:
-            warnings.filterwarnings("ignore",category=DeprecationWarning)
-            res = ufl.log2(a)
-            assert_almost_equal(res, tgt)
-            res = ufl.log2(a, out)
-            assert_almost_equal(res, tgt)
-            assert_almost_equal(out, tgt)
-        except DeprecationWarning:
-            pass
+        res = ufl.log2(a)
+        assert_almost_equal(res, tgt)
+        res = ufl.log2(a, out)
+        assert_almost_equal(res, tgt)
+        assert_almost_equal(out, tgt)
 
     def test_fix(self):
         a = nx.array([[1.0, 1.1, 1.5, 1.8], [-1.0, -1.1, -1.5, -1.8]])

Modified: trunk/numpy/lib/ufunclike.py
===================================================================
--- trunk/numpy/lib/ufunclike.py	2010-04-14 17:17:53 UTC (rev 8333)
+++ trunk/numpy/lib/ufunclike.py	2010-04-14 17:24:50 UTC (rev 8334)
@@ -5,7 +5,6 @@
 __all__ = ['fix', 'isneginf', 'isposinf']
 
 import numpy.core.numeric as nx
-import warnings
 
 def fix(x, y=None):
     """
@@ -174,6 +173,7 @@
     nx.logical_and(nx.isinf(x), nx.signbit(x), y)
     return y
 
+
 _log2 = nx.log(2)
 def log2(x, y=None):
     """
@@ -203,6 +203,7 @@
     array([ NaN,   1.,   2.])
 
     """
+    import warnings
     msg = "numpy.lib.log2 is deprecated, use np.log2 instead."
     warnings.warn(msg, DeprecationWarning)
 




More information about the Numpy-svn mailing list