|
21 | 21 | pytestmark = pytest.mark.usefixtures("mplcleanup") |
22 | 22 |
|
23 | 23 |
|
24 | | -def test_siso(): |
25 | | - """Test SISO frequency response""" |
| 24 | +@pytest.fixture |
| 25 | +def ss_siso(): |
26 | 26 | A = np.array([[1, 1], [0, 1]]) |
27 | 27 | B = np.array([[0], [1]]) |
28 | 28 | C = np.array([[1, 0]]) |
29 | 29 | D = 0 |
30 | | - sys = StateSpace(A, B, C, D) |
| 30 | + return StateSpace(A, B, C, D) |
| 31 | + |
| 32 | + |
| 33 | +@pytest.fixture |
| 34 | +def ss_mimo(): |
| 35 | + A = np.array([[1, 1], [0, 1]]) |
| 36 | + B = np.array([[1, 0], [0, 1]]) |
| 37 | + C = np.array([[1, 0]]) |
| 38 | + D = np.array([[0, 0]]) |
| 39 | + return StateSpace(A, B, C, D) |
| 40 | + |
| 41 | +def test_freqresp_siso(ss_siso): |
| 42 | + """Test SISO frequency response""" |
31 | 43 | omega = np.linspace(10e-2, 10e2, 1000) |
32 | 44 |
|
33 | 45 | # test frequency response |
34 | | - sys.frequency_response(omega) |
| 46 | + ctrl.freqresp(ss_siso, omega) |
35 | 47 |
|
36 | | - # test bode plot |
37 | | - bode(sys) |
38 | 48 |
|
39 | | - # Convert to transfer function and test bode |
40 | | - systf = tf(sys) |
41 | | - bode(systf) |
| 49 | +@slycotonly |
| 50 | +def test_freqresp_mimo(ss_mimo): |
| 51 | + """Test MIMO frequency response calls""" |
| 52 | + omega = np.linspace(10e-2, 10e2, 1000) |
| 53 | + ctrl.freqresp(ss_mimo, omega) |
| 54 | + tf_mimo = tf(ss_mimo) |
| 55 | + ctrl.freqresp(tf_mimo, omega) |
| 56 | + |
| 57 | + |
| 58 | +def test_bode_basic(ss_siso): |
| 59 | + """Test bode plot call (Very basic)""" |
| 60 | + # TODO: proper test |
| 61 | + tf_siso = tf(ss_siso) |
| 62 | + bode(ss_siso) |
| 63 | + bode(tf_siso) |
42 | 64 |
|
43 | 65 |
|
44 | 66 | @pytest.mark.filterwarnings("ignore:.*non-positive left xlim:UserWarning") |
@@ -106,20 +128,6 @@ def test_doubleint(): |
106 | 128 | bode(sys) |
107 | 129 |
|
108 | 130 |
|
109 | | -@slycotonly |
110 | | -def test_mimo(): |
111 | | - """Test MIMO frequency response calls""" |
112 | | - A = np.array([[1, 1], [0, 1]]) |
113 | | - B = np.array([[1, 0], [0, 1]]) |
114 | | - C = np.array([[1, 0]]) |
115 | | - D = np.array([[0, 0]]) |
116 | | - omega = np.linspace(10e-2, 10e2, 1000) |
117 | | - sysMIMO = ss(A, B, C, D) |
118 | | - |
119 | | - sysMIMO.frequency_response(omega) |
120 | | - tf(sysMIMO) |
121 | | - |
122 | | - |
123 | 131 | @pytest.mark.parametrize( |
124 | 132 | "Hz, Wcp, Wcg", |
125 | 133 | [pytest.param(False, 6.0782869, 10., id="omega"), |
|
0 commit comments