[Numpy-svn] r8309 - in branches/1.4.x/numpy/lib: . tests

numpy-svn@scip... numpy-svn@scip...
Tue Mar 30 21:33:14 CDT 2010


Author: cdavid
Date: 2010-03-30 21:33:13 -0500 (Tue, 30 Mar 2010)
New Revision: 8309

Modified:
   branches/1.4.x/numpy/lib/function_base.py
   branches/1.4.x/numpy/lib/tests/test_function_base.py
Log:
BUG: fix kaiser for M=1.

Modified: branches/1.4.x/numpy/lib/function_base.py
===================================================================
--- branches/1.4.x/numpy/lib/function_base.py	2010-03-31 02:26:14 UTC (rev 8308)
+++ branches/1.4.x/numpy/lib/function_base.py	2010-03-31 02:33:13 UTC (rev 8309)
@@ -2612,6 +2612,8 @@
 
     """
     from numpy.dual import i0
+    if M == 1:
+        return np.array([1.])
     n = arange(0,M)
     alpha = (M-1)/2.0
     return i0(beta * sqrt(1-((n-alpha)/alpha)**2.0))/i0(float(beta))

Modified: branches/1.4.x/numpy/lib/tests/test_function_base.py
===================================================================
--- branches/1.4.x/numpy/lib/tests/test_function_base.py	2010-03-31 02:26:14 UTC (rev 8308)
+++ branches/1.4.x/numpy/lib/tests/test_function_base.py	2010-03-31 02:33:13 UTC (rev 8309)
@@ -772,15 +772,15 @@
 
 class TestKaiser(TestCase):
     def test_simple(self):
-        assert_almost_equal(kaiser(0,1.0), array([]))
-        assert isnan(kaiser(1,1.0))
-        assert_almost_equal(kaiser(2,1.0), array([ 0.78984831,  0.78984831]))
-        assert_almost_equal(kaiser(5,1.0),
-                            array([ 0.78984831,  0.94503323,  1.        ,
-                                    0.94503323,  0.78984831]))
-        assert_almost_equal(kaiser(5,1.56789),
-                            array([ 0.58285404,  0.88409679,  1.        ,
-                                    0.88409679,  0.58285404]))
+        assert_almost_equal(kaiser(0, 1.0), array([]))
+        assert isfinite(kaiser(1, 1.0))
+        assert_almost_equal(kaiser(2, 1.0), array([ 0.78984831, 0.78984831]))
+        assert_almost_equal(kaiser(5, 1.0),
+                            array([ 0.78984831, 0.94503323, 1.        ,
+                                    0.94503323, 0.78984831]))
+        assert_almost_equal(kaiser(5, 1.56789),
+                            array([ 0.58285404, 0.88409679, 1.        ,
+                                    0.88409679, 0.58285404]))
 
     def test_int_beta(self):
         kaiser(3, 4)



More information about the Numpy-svn mailing list