[Scipy-svn] r6303 - trunk/scipy/signal/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Apr 3 17:00:13 EDT 2010


Author: warren.weckesser
Date: 2010-04-03 16:00:13 -0500 (Sat, 03 Apr 2010)
New Revision: 6303

Modified:
   trunk/scipy/signal/tests/test_filter_design.py
Log:
TEST: Add a test for scipy.signal.firwin.

Modified: trunk/scipy/signal/tests/test_filter_design.py
===================================================================
--- trunk/scipy/signal/tests/test_filter_design.py	2010-04-03 19:38:44 UTC (rev 6302)
+++ trunk/scipy/signal/tests/test_filter_design.py	2010-04-03 21:00:13 UTC (rev 6303)
@@ -3,8 +3,9 @@
 import numpy as np
 from numpy.testing import TestCase, assert_array_almost_equal
 
-from scipy.signal import tf2zpk, bessel, BadCoefficients
+from scipy.signal import tf2zpk, bessel, BadCoefficients, kaiserord, firwin, freqz
 
+
 class TestTf2zpk(TestCase):
     def test_simple(self):
         z_r = np.array([0.5, -0.5])
@@ -36,3 +37,14 @@
         finally:
             warnings.simplefilter("always", BadCoefficients)
 
+
+class TestFirWin(TestCase):
+    
+    def test_lowpass(self):
+        width = 0.04
+        ntaps, beta = kaiserord(120, width)
+        taps = firwin(ntaps, cutoff=0.5, window=('kaiser', beta))
+        freq_samples = np.array([0.0, 0.25, 0.5-width/2, 0.5+width/2, 0.75, 1.0])
+        freqs, response = freqz(taps, worN=np.pi*freq_samples)
+        assert_array_almost_equal(np.abs(response),
+                                    [1.0, 1.0, 1.0, 0.0, 0.0, 0.0], decimal=5)




More information about the Scipy-svn mailing list