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

scipy-svn at scipy.org scipy-svn at scipy.org
Thu Nov 6 06:56:06 EST 2008


Author: cdavid
Date: 2008-11-06 05:55:41 -0600 (Thu, 06 Nov 2008)
New Revision: 4999

Modified:
   trunk/scipy/signal/tests/test_filter_design.py
Log:
Check the warning works as expected for #651 case.

Modified: trunk/scipy/signal/tests/test_filter_design.py
===================================================================
--- trunk/scipy/signal/tests/test_filter_design.py	2008-11-06 11:54:41 UTC (rev 4998)
+++ trunk/scipy/signal/tests/test_filter_design.py	2008-11-06 11:55:41 UTC (rev 4999)
@@ -1,7 +1,9 @@
+import warnings
+
 import numpy as np
 from numpy.testing import TestCase, assert_array_almost_equal
 
-from scipy.signal import tf2zpk
+from scipy.signal import tf2zpk, bessel, BadCoefficients
 
 class TestTf2zpk(TestCase):
     def test_simple(self):
@@ -19,3 +21,18 @@
         p.sort()
         assert_array_almost_equal(z, z_r)
         assert_array_almost_equal(p, p_r)
+
+    def test_bad_filter(self):
+        """Regression test for #651: better handling of badly conditionned
+        filter coefficients."""
+        b, a = bessel(20, 0.1)
+        warnings.simplefilter("error", BadCoefficients)
+        try:
+            try:
+                z, p, k = tf2zpk(b, a)
+                raise AssertionError("tf2zpk did not warn about bad "\
+                                     "coefficients")
+            except BadCoefficients:
+                pass
+        finally:
+            warnings.simplefilter("always", BadCoefficients)




More information about the Scipy-svn mailing list