[Scipy-svn] r7125 - in trunk/scipy/signal: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Feb 6 14:11:28 EST 2011
Author: warren.weckesser
Date: 2011-02-06 13:11:27 -0600 (Sun, 06 Feb 2011)
New Revision: 7125
Modified:
trunk/scipy/signal/filter_design.py
trunk/scipy/signal/tests/test_filter_design.py
Log:
BUG: signal: zpk2tf returns a scalar 1.0 for the denominator when the list of poles was empty (ticket #990). Thanks to asomers for the patch.
Modified: trunk/scipy/signal/filter_design.py
===================================================================
--- trunk/scipy/signal/filter_design.py 2011-02-04 18:32:04 UTC (rev 7124)
+++ trunk/scipy/signal/filter_design.py 2011-02-06 19:11:27 UTC (rev 7125)
@@ -243,7 +243,7 @@
b[i] = k[i] * poly(z[i])
else:
b = k * poly(z)
- a = poly(p)
+ a = atleast_1d(poly(p))
return b, a
def normalize(b, a):
Modified: trunk/scipy/signal/tests/test_filter_design.py
===================================================================
--- trunk/scipy/signal/tests/test_filter_design.py 2011-02-04 18:32:04 UTC (rev 7124)
+++ trunk/scipy/signal/tests/test_filter_design.py 2011-02-06 19:11:27 UTC (rev 7125)
@@ -1,9 +1,10 @@
import warnings
import numpy as np
-from numpy.testing import TestCase, assert_array_almost_equal, assert_raises
+from numpy.testing import TestCase, assert_array_almost_equal, \
+ assert_array_equal, assert_raises, assert_
-from scipy.signal import tf2zpk, bessel, BadCoefficients
+from scipy.signal import tf2zpk, zpk2tf, bessel, BadCoefficients
class TestTf2zpk(TestCase):
@@ -32,3 +33,22 @@
assert_raises(BadCoefficients, tf2zpk, [1e-15], [1.0, 1.0])
finally:
warnings.simplefilter("always", BadCoefficients)
+
+
+class TestZpk2Tf(TestCase):
+
+ def test_identity(self):
+ """Test the identity transfer function."""
+ z = []
+ p = []
+ k = 1.
+ b, a = zpk2tf(z, p, k)
+ b_r = np.array([1.]) # desired result
+ a_r = np.array([1.]) # desired result
+ # The test for the *type* of the return values is a regression
+ # test for ticket #1095. In the case p=[], zpk2tf used to
+ # return the scalar 1.0 instead of array([1.0]).
+ assert_array_equal(b, b_r)
+ assert_(isinstance(b, np.ndarray))
+ assert_array_equal(a, a_r)
+ assert_(isinstance(a, np.ndarray))
More information about the Scipy-svn
mailing list