def test_dc_gain(self): self.assertEqual(tf([1, 2], [1, 1, 0]).dc_gain, float('inf'))
def test_tf(self): assert_tf_equal(tf([1], [1, 0]), TransferFunction([1], [1, 0])) assert_tf_equal(tf(TransferFunction([1], [1, 0])), tf([1], [1, 0])) assert_tf_equal(tf(num=[1], den=[1, 0]), tf([1], [1, 0]))
def test___add__(self): assert_tf_equal(self.s3 + self.s4, self.s6) assert_tf_equal(self.s3 + 1, tf([1, 1], [1, 0]))
def test___mul__(self): assert_tf_equal(self.s3 * self.s4, self.s7) assert_tf_equal(self.s3 * 0.5, tf([0.5], [1, 0]))
def test__cascade(self): sys_ = tf([4, 0, 0], [1, 8, 22, 24, 9, 0]) assert_tf_equal(self.s3.cascade(self.s4, self.s4), sys_)
def test_parallel(self): sys_ = tf([5, 24, 34, 24, 9], [1, 8, 22, 24, 9, 0]) assert_tf_equal(self.s3.parallel(self.s4, self.s4), sys_) assert_tf_equal(self.s3.parallel(self.s3), tf([2], [1, 0]))
def test_pzmap_discrete_time(self): system = tf([1], [1, 1], 1) pzmap(system, plot=False)
def test_pzmap_random_data(self): sys_ = [tf(*i) for i in SYSTEMS] for i in sys_: p, z = pzmap(i, plot=False) self.assertTrue(all(np.equal(p, np.roots(i.den)))) self.assertTrue(all(np.equal(z, np.roots(i.num))))
def test_pzmap(self): sys_ = tf([1, 2, 2], [1, 2, 1, 1]) p, z = pzmap(sys_, plot=False) self.assertTrue(all(np.equal(p, np.roots(sys_.den)))) self.assertTrue(all(np.equal(z, np.roots(sys_.num))))