import warnings

import numpy as np
from numpy.testing import TestCase, assert_array_almost_equal

from scipy.signal import tf2zpk, bessel, BadCoefficients

class TestTf2zpk(TestCase):
    def test_simple(self):
        z_r = np.array([0.5, -0.5])
        p_r = np.array([1.j / np.sqrt(2), -1.j / np.sqrt(2)])
        # Sort the zeros/poles so that we don't fail the test if the order
        # changes
        z_r.sort()
        p_r.sort()
        b = np.poly(z_r)
        a = np.poly(p_r)

        z, p, k = tf2zpk(b, a)
        z.sort()
        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 conditioned
        filter coefficients."""
        warnings.simplefilter("error", BadCoefficients)
        try:
            b, a = bessel(20, 0.1)
            z, p, k = tf2zpk(b, a)
            raise AssertionError("tf2zpk did not warn about bad "\
                                 "coefficients")
        except BadCoefficients:
            pass
        finally:
            warnings.simplefilter("always", BadCoefficients)


@@ -148,16 +148,43 @@
 ficients
+, kaiserord, firwin, freqz%0A
 %0A%0Aclass 
@@ -1182,8 +1182,477 @@
 ients)%0A%0A
+%0Aclass TestFirWin(TestCase):%0A    %0A    def test_lowpass(self):%0A        width = 0.04%0A        ntaps, beta = kaiserord(120, width)%0A        taps = firwin(ntaps, cutoff=0.5, window=('kaiser', beta))%0A        freq_samples = np.array(%5B0.0, 0.25, 0.5-width/2, 0.5+width/2, 0.75, 1.0%5D)%0A        freqs, response = freqz(taps, worN=np.pi*freq_samples)%0A        assert_array_almost_equal(np.abs(response),%0A                                    %5B1.0, 1.0, 1.0, 0.0, 0.0, 0.0%5D, decimal=5)%0A

Add a test for scipy.signal.firwin.