# [Scipy-svn] r4977 - trunk/scipy/signal/tests

scipy-svn@scip... scipy-svn@scip...
Mon Nov 3 23:24:27 CST 2008

Author: cdavid
Date: 2008-11-03 23:24:19 -0600 (Mon, 03 Nov 2008)
New Revision: 4977

Modified:
trunk/scipy/signal/tests/test_signaltools.py
Log:
Add basic tests for zi argument.

Modified: trunk/scipy/signal/tests/test_signaltools.py
===================================================================
--- trunk/scipy/signal/tests/test_signaltools.py	2008-11-04 05:23:58 UTC (rev 4976)
+++ trunk/scipy/signal/tests/test_signaltools.py	2008-11-04 05:24:19 UTC (rev 4977)
@@ -116,5 +116,24 @@
y_r = np.array([0, 1, 3, 5, 7, 9.])
assert_array_almost_equal(lfilter(b, a, x), y_r)

+        # Test IIR with initial conditions
+        b = np.array([1, 1])
+        a = np.array([1])
+        zi = np.array([1])
+        y_r = np.array([1, 1, 3, 5, 7, 9.])
+        zf_r = np.array([5])
+        y, zf = lfilter(b, a, x, zi=zi)
+        assert_array_almost_equal(y, y_r)
+        assert_array_almost_equal(zf, zf_r)
+
+        b = np.array([1, 1, 1])
+        a = np.array([1])
+        zi = np.array([1, 1])
+        y_r = np.array([1, 2, 3, 6, 9, 12.])
+        zf_r = np.array([9, 5])
+        y, zf = lfilter(b, a, x, zi=zi)
+        assert_array_almost_equal(y, y_r)
+        assert_array_almost_equal(zf, zf_r)
+
if __name__ == "__main__":
run_module_suite()