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

numpy-svn@scip... numpy-svn@scip...
Sun Jun 27 06:07:15 CDT 2010


Author: ptvirtan
Date: 2010-06-27 06:07:15 -0500 (Sun, 27 Jun 2010)
New Revision: 8465

Modified:
   trunk/numpy/lib/function_base.py
   trunk/numpy/lib/tests/test_function_base.py
Log:
BUG: lib: fix sinc to handle array-like inputs properly (fixes #1523)

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2010-06-19 13:44:47 UTC (rev 8464)
+++ trunk/numpy/lib/function_base.py	2010-06-27 11:07:15 UTC (rev 8465)
@@ -2737,6 +2737,7 @@
     <matplotlib.image.AxesImage object at 0x...>
 
     """
+    x = np.asanyarray(x)
     y = pi* where(x == 0, 1.0e-20, x)
     return sin(y)/y
 

Modified: trunk/numpy/lib/tests/test_function_base.py
===================================================================
--- trunk/numpy/lib/tests/test_function_base.py	2010-06-19 13:44:47 UTC (rev 8464)
+++ trunk/numpy/lib/tests/test_function_base.py	2010-06-27 11:07:15 UTC (rev 8465)
@@ -499,6 +499,13 @@
         #check symmetry
         assert_array_almost_equal(w, flipud(w), 7)
 
+    def test_array_like(self):
+        x = [0, 0.5]
+        y1 = sinc(array(x))
+        y2 = sinc(list(x))
+        y3 = sinc(tuple(x))
+        assert_array_equal(y1, y2)
+        assert_array_equal(y1, y3)
 
 class TestHistogram(TestCase):
     def setUp(self):



More information about the Numpy-svn mailing list