forked from python-control/python-control
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_element_int_test.py
More file actions
54 lines (42 loc) · 1.47 KB
/
Copy pathinput_element_int_test.py
File metadata and controls
54 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# input_element_int_test.py
#
# Author: Kangwon Lee (kangwonlee)
# Date: 22 Oct 2017
#
# Unit tests contributed as part of PR #158, "SISO tf() may not work
# with numpy arrays with numpy.int elements"
#
# Modified:
# * 29 Dec 2017, RMM - updated file name and added header
import unittest
import numpy as np
import control as ctl
class TestTfInputIntElement(unittest.TestCase):
# currently these do not pass
def test_tf_den_with_numpy_int_element(self):
num = 1
den = np.convolve([1, 2, 1], [1, 1, 1])
sys = ctl.tf(num, den)
self.assertAlmostEqual(1.0, ctl.dcgain(sys))
def test_tf_num_with_numpy_int_element(self):
num = np.convolve([1], [1, 1])
den = np.convolve([1, 2, 1], [1, 1, 1])
sys = ctl.tf(num, den)
self.assertAlmostEqual(1.0, ctl.dcgain(sys))
# currently these pass
def test_tf_input_with_int_element_works(self):
num = 1
den = np.convolve([1.0, 2, 1], [1, 1, 1])
sys = ctl.tf(num, den)
self.assertAlmostEqual(1.0, ctl.dcgain(sys))
def test_ss_input_with_int_element(self):
ident = np.matrix(np.identity(2), dtype=int)
a = np.matrix([[0, 1],
[-1, -2]], dtype=int) * ident
b = np.matrix([[0],
[1]], dtype=int)
c = np.matrix([[0, 1]], dtype=int)
d = 0
sys = ctl.ss(a, b, c, d)
sys2 = ctl.ss2tf(sys)
self.assertAlmostEqual(ctl.dcgain(sys), ctl.dcgain(sys2))