|
| 1 | +import unittest |
| 2 | + |
| 3 | +import numpy as np |
| 4 | + |
| 5 | +import control as ctl |
| 6 | + |
| 7 | + |
| 8 | +class TestTfInputIntElement(unittest.TestCase): |
| 9 | + # currently these do not pass |
| 10 | + def test_tf_den_with_numpy_int_element(self): |
| 11 | + num = 1 |
| 12 | + den = np.convolve([1, 2, 1], [1, 1, 1]) |
| 13 | + |
| 14 | + sys = ctl.tf(num, den) |
| 15 | + |
| 16 | + self.assertAlmostEqual(1.0, ctl.dcgain(sys)) |
| 17 | + |
| 18 | + def test_tf_num_with_numpy_int_element(self): |
| 19 | + num = np.convolve([1], [1, 1]) |
| 20 | + den = np.convolve([1, 2, 1], [1, 1, 1]) |
| 21 | + |
| 22 | + sys = ctl.tf(num, den) |
| 23 | + |
| 24 | + self.assertAlmostEqual(1.0, ctl.dcgain(sys)) |
| 25 | + |
| 26 | + # currently these pass |
| 27 | + def test_tf_input_with_int_element_works(self): |
| 28 | + num = 1 |
| 29 | + den = np.convolve([1.0, 2, 1], [1, 1, 1]) |
| 30 | + |
| 31 | + sys = ctl.tf(num, den) |
| 32 | + |
| 33 | + self.assertAlmostEqual(1.0, ctl.dcgain(sys)) |
| 34 | + |
| 35 | + def test_ss_input_with_int_element(self): |
| 36 | + ident = np.matrix(np.identity(2), dtype=int) |
| 37 | + a = np.matrix([[0, 1], |
| 38 | + [-1, -2]], dtype=int) * ident |
| 39 | + b = np.matrix([[0], |
| 40 | + [1]], dtype=int) |
| 41 | + c = np.matrix([[0, 1]], dtype=int) |
| 42 | + d = 0 |
| 43 | + |
| 44 | + sys = ctl.ss(a, b, c, d) |
| 45 | + sys2 = ctl.ss2tf(sys) |
| 46 | + self.assertAlmostEqual(ctl.dcgain(sys), ctl.dcgain(sys2)) |
0 commit comments