コード例 #1
0
 def test_buttord_2(self):
     # Test case for highpass filter
     self.assertTrue(
         np.all(
             IIRDesign.buttord(self.f2, self.f1, self.Rp, self.Rs) ==
             signal.buttord(
                 self.f2, self.f1, self.Rp, self.Rs, analog=False, fs=2)))
コード例 #2
0
 def test_polystab(self):
     # test case
     x = [1, -2, -3]
     v = np.roots(x)
     vs = 0.5 * (np.sign(np.abs(v) - 1) + 1)
     v = (1 - vs) * v + vs / np.conj(v)
     b = x[0] * np.poly(v)
     self.assertTrue(np.all(IIRDesign.polystab(self.a) == b))
コード例 #3
0
 def test_impz_4(self):
     # Test case for IIR filter with n
     fil = IIRDesign.butter(6, self.fc / (self.fs / 2))
     dl = signal.dlti(fil[0], fil[1], dt=1 / self.fs)
     i_d = signal.dimpulse(dl, n=self.n)
     T = i_d[0]
     yout = i_d[1][0]
     tt, y = FilterSpec.impz(fil, n=self.n, fs=self.fs)
     self.assertTrue(np.all(tt == T) and np.all(y == yout))
コード例 #4
0
 def test_ellipord_3(self):
     # Test case for bandpass filter
     ORD = IIRDesign.ellipord(self.f3, self.f4, self.Rp, self.Rs)
     ord = signal.ellipord(self.f3,
                           self.f4,
                           self.Rp,
                           self.Rs,
                           analog=False,
                           fs=2)
     self.assertTrue((ORD[0] == ord[0]) and np.all(ORD[1] == ord[1]))
コード例 #5
0
 def test_buttord_4(self):
     # Test case for bandstop filter
     ORD = IIRDesign.buttord(self.f4, self.f3, self.Rp, self.Rs)
     ord = signal.buttord(self.f4,
                          self.f3,
                          self.Rp,
                          self.Rs,
                          analog=False,
                          fs=2)
     self.assertTrue((ORD[0] == ord[0]) and (ORD[1] == ord[1]).all())
コード例 #6
0
 def test_cheb1ord_9(self):
     # Test case for Exception 4
     with self.assertRaises(ValueError):
         IIRDesign.cheb1ord(self.f3, [0.1, 0.6, 0.7], self.Rp, self.Rs)
コード例 #7
0
 def test_cheb1ord_7(self):
     # Test case for Exception 2
     with self.assertRaises(ValueError):
         IIRDesign.cheb1ord(0.2, 75, self.Rp, self.Rs)
コード例 #8
0
 def test_cheb1ord_5(self):
     # Test case for analog filter
     self.assertTrue(np.all(IIRDesign.cheb1ord(60, 75, self.Rp, self.Rs, zs='s') == signal.cheb1ord(60, 75, self.Rp, self.Rs, analog=True, fs=None)))
コード例 #9
0
 def test_ellip_16(self):
     # test case for Exception 9
     with self.assertRaises(ValueError):
         IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wp1, ftype='bandpass')
コード例 #10
0
 def test_ellip_14(self):
     # test case for Exception 7
     with self.assertRaises(ValueError):
         IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wp2, ftype='high')
コード例 #11
0
 def test_ellip_11(self):
     # test case for Exception 4
     with self.assertRaises(ValueError):
         IIRDesign.ellip(self.n, self.Rp, self.Rs, 1.4, zs='z')
コード例 #12
0
 def test_cheby1_15(self):
     # Test case for exception 8
     with self.assertRaises(ValueError):
         IIRDesign.cheby1(self.n, self.Rp, self.Wp1, ftype='stop')
コード例 #13
0
 def test_cheby1_14(self):
     # Test case for exception 7
     with self.assertRaises(ValueError):
         IIRDesign.cheby1(self.n, self.Rp, self.Wp2, ftype='high')
コード例 #14
0
 def test_cheby1_11(self):
     # Test case for exception 4
     with self.assertRaises(ValueError):
         IIRDesign.cheby1(self.n, self.Rp, self.Wps, ftype='low')
コード例 #15
0
 def test_cheby1_10(self):
     # Test case for exception 3
     with self.assertRaises(ValueError):
         IIRDesign.cheby1(2.5, self.Rp, self.Wp2, ftype='bandpass')
コード例 #16
0
 def test_ellip_8(self):
     # test case for Exception 1
     with self.assertRaises(ValueError):
         IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wps, zs='x')
コード例 #17
0
 def test_ellip_9(self):
     # test case for Exception 2
     with self.assertRaises(ValueError):
         IIRDesign.ellip(2.5, self.Rp, self.Rs, self.Wp1)
コード例 #18
0
 def test_cheby1_16(self):
     # Test case for exception 9
     with self.assertRaises(ValueError):
         IIRDesign.cheby1(self.n, self.Rp, self.Wp1, ftype='bandpass')
コード例 #19
0
 def test_ellip_12(self):
     # test case for Exception 5
     with self.assertRaises(ValueError):
         IIRDesign.ellip(self.n, self.Rp, self.Rs, [0.5, 1.5], zs='z')
コード例 #20
0
 def test_polyscale(self):
     # Test case
     self.assertTrue(
         np.all(
             IIRDesign.polyscale(self.a, self.alpha) == (self.alpha *
                                                         np.roots(self.a))))
コード例 #21
0
 def test_ellip_15(self):
     # test case for Exception 8
     with self.assertRaises(ValueError):
         IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wp1, ftype='stop')
コード例 #22
0
 def test_ellip_1(self):
     # Test case for lowpass filter with default
     IIR = IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wp1)
     iir = signal.ellip(self.n, self.Rp, self.Rs, self.Wp1, btype='lowpass', fs=2)
     self.assertTrue((IIR[0] == iir[0]).all() and (IIR[1] == iir[1]).all())
コード例 #23
0
 def test_cheb1ord_1(self):
     # Test case for lowpass filter
     self.assertTrue(np.all(IIRDesign.cheb1ord(self.f1, self.f2, self.Rp, self.Rs) == signal.cheb1ord(self.f1, self.f2, self.Rp, self.Rs, analog=False, fs=2)))
コード例 #24
0
 def test_ellip_3(self):
     # Test case for highpass filter
     IIR = IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wp1, ftype='high')
     iir = signal.ellip(self.n, self.Rp, self.Rs, self.Wp1, btype='highpass', fs=2)
     self.assertTrue((IIR[0] == iir[0]).all() and (IIR[1] == iir[1]).all())
コード例 #25
0
 def test_cheb1ord_6(self):
     # Test case for Exception 1
     with self.assertRaises(ValueError):
         IIRDesign.cheb1ord(60, 75, self.Rp, self.Rs, zs='x')
コード例 #26
0
 def test_ellip_5(self):
     # Test case for bandpass filter without default
     IIR = IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wp2, ftype='bandpass')
     iir = signal.ellip(self.n, self.Rp, self.Rs, self.Wp2, btype='bandpass', fs=2)
     self.assertTrue((IIR[0] == iir[0]).all() and (IIR[1] == iir[1]).all())
コード例 #27
0
 def test_cheb1ord_8(self):
     # Test case for Exception 3
     with self.assertRaises(ValueError):
         IIRDesign.cheb1ord(self.f3, [1, 6], self.Rp, self.Rs)
コード例 #28
0
 def test_ellip_6(self):
     # Test case for bandstop filter
     IIR = IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wp2, ftype='stop')
     iir = signal.ellip(self.n, self.Rp, self.Rs, self.Wp2, btype='bandstop', fs=2)
     self.assertTrue((IIR[0] == iir[0]).all() and (IIR[1] == iir[1]).all())
コード例 #29
0
 def test_cheb1ord_11(self):
     # Test case for Exception 6
     with self.assertRaises(ValueError):
         IIRDesign.cheb1ord(self.f1, self.f2, self.Rp, 'x')
         
コード例 #30
0
 def test_ellip_7(self):
     # Test case for analog filter
     IIR = IIRDesign.ellip(self.n, self.Rp, self.Rs, self.Wps, zs='s')
     iir = signal.ellip(self.n, self.Rp, self.Rs, self.Wps, btype='lowpass', analog=True)
     self.assertTrue((IIR[0] == iir[0]).all() and (IIR[1] == iir[1]).all())