-
Notifications
You must be signed in to change notification settings - Fork 453
Expand file tree
/
Copy pathinput_element_int_test.py
More file actions
66 lines (49 loc) · 1.78 KB
/
input_element_int_test.py
File metadata and controls
66 lines (49 loc) · 1.78 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
55
56
57
58
59
60
61
62
63
64
65
66
"""input_element_int_test.py
Author: Kangwon Lee (kangwonlee)
Date: 22 Oct 2017
Modified:
* 29 Dec 2017, RMM - updated file name and added header
"""
import numpy as np
from control import dcgain, ss, tf
class TestTfInputIntElement:
"""input_element_int_test
Unit tests contributed as part of PR gh-158, "SISO tf() may not work
with numpy arrays with numpy.int elements
"""
def test_tf_den_with_numpy_int_element(self):
num = 1
den = np.convolve([1, 2, 1], [1, 1, 1])
sys = tf(num, den)
np.testing.assert_almost_equal(1., 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 = tf(num, den)
np.testing.assert_almost_equal(1., dcgain(sys))
# currently these pass
def test_tf_input_with_int_element(self):
num = 1
den = np.convolve([1.0, 2, 1], [1, 1, 1])
sys = tf(num, den)
np.testing.assert_almost_equal(1., dcgain(sys))
def test_ss_input_with_int_element(self):
a = np.array([[0, 1],
[-1, -2]], dtype=int)
b = np.array([[0],
[1]], dtype=int)
c = np.array([[0, 1]], dtype=int)
d = np.array([[1]], dtype=int)
sys = ss(a, b, c, d)
sys2 = tf(sys)
np.testing.assert_almost_equal(dcgain(sys), dcgain(sys2))
def test_ss_input_with_0int_dcgain(self):
a = np.array([[0, 1],
[-1, -2]], dtype=int)
b = np.array([[0],
[1]], dtype=int)
c = np.array([[0, 1]], dtype=int)
d = 0
sys = ss(a, b, c, d)
np.testing.assert_allclose(dcgain(sys), 0,
atol=np.finfo(float).epsneg)