diff options
author | David Cournapeau <cournape@gmail.com> | 2010-03-31 02:33:13 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2010-03-31 02:33:13 +0000 |
commit | 25f230bc9e1675fabcabb6dbd0d7798921c9a082 (patch) | |
tree | f3995ec4aef155912841966855208503d569986d | |
parent | 09996899f1aca598086b6690ed04b2590db82385 (diff) | |
download | numpy-25f230bc9e1675fabcabb6dbd0d7798921c9a082.tar.gz |
BUG: fix kaiser for M=1.
-rw-r--r-- | numpy/lib/function_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 76ea08dfb..7b0984a03 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2612,6 +2612,8 @@ def kaiser(M,beta): """ 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)) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 8595c6b5c..af5feadc7 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -772,15 +772,15 @@ class Test_i0(TestCase): 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) |