|
27 | 27 |
|
28 | 28 | from .conftest import editsdefaults
|
29 | 29 |
|
30 |
| -from .linfnorm_mimo_testcases import continuous_time_mimo, discrete_time_mimo |
31 | 30 |
|
32 | 31 | class TestStateSpace:
|
33 | 32 | """Tests for the StateSpace class."""
|
@@ -1102,83 +1101,50 @@ def test_latex_repr_testsize(editsdefaults):
|
1102 | 1101 | assert gstatic._repr_latex_() is None
|
1103 | 1102 |
|
1104 | 1103 |
|
1105 |
| -# these are relatively simple examples |
1106 |
| -# the underdamped gpeak and fpeak are found from |
1107 |
| -# gpeak = 1/(2*zeta*(1-zeta**2)**0.5 |
1108 |
| -# fpeak = wn*(1-2*zeta**2)**0.5 |
1109 |
| -@pytest.fixture(params=[ |
1110 |
| - ('lpf', ct.tf, ([1],[1,1]), 1, 0), |
1111 |
| - ('static', ct.tf, ([1.23],[1]), 1.23, 0), |
1112 |
| - ('underdamped', ct.tf, ([100],[1, 2*0.1*10, 100]), 5.02518907629606, 9.89949493661), |
1113 |
| - ('hpf', ct.tf, ([1, 0], [1, 1]), 1, np.inf), |
1114 |
| - ('integrator', ct.tf, ([1],[1,0]), np.inf, 0), |
1115 |
| - ('undamped', ct.tf, ([1],[1, 0, 144]), np.inf, 12), |
1116 |
| - ('zero', ct.ss, ([-1],[1],[0],[0]), 0, 0), |
1117 |
| - ]) |
1118 |
| -def continuous_time_siso(request): |
1119 |
| - name, systype, sysargs, refgpeak, reffpeak = request.param |
1120 |
| - return systype(*sysargs), refgpeak, reffpeak |
1121 |
| - |
1122 |
| -# these are the continuous-time examples with some tweaks |
1123 |
| -@pytest.fixture(params=[ |
1124 |
| - ('lpf', ct.tf, ([1],[1,1]), 0.1, 1, 0), |
1125 |
| - ('static', ct.tf, ([1.23],[1]), 0.1, 1.23, 0), |
1126 |
| - # the gain and frequency don't quite match the continuous-time case, |
1127 |
| - # I assume due to c2d imperfection |
1128 |
| - ('underdamped', ct.tf, ([100],[1, 2*0.1*10, 100]), 0.01, 5.023137, 9.899412), |
1129 |
| - # The HPF fpeak is the Nyquist frequency |
1130 |
| - # Assume gpeak mismatch is again c2d mismatch |
1131 |
| - ('hpf', ct.tf, ([1, 0], [1, 1]), 0.1, 1.04995845, np.pi * 10), |
1132 |
| - ('integrator', ct.tf, ([1],[1,0]), 0.1, np.inf, 0), |
1133 |
| - ('undamped', ct.tf, ([1],[1, 0, 144]), 0.003, np.inf, 12), |
1134 |
| - # ss call works around Scipy's "Badly conditioned filter coefficients" warning |
1135 |
| - ('zero', ct.ss, ([-1],[1],[0],[0]), 0.003, 0, 0), |
1136 |
| - ]) |
1137 |
| -def discrete_time_siso(request): |
1138 |
| - name, systype, sysargs, dt, refgpeak, reffpeak = request.param |
1139 |
| - return ct.c2d(systype(*sysargs), dt), refgpeak, reffpeak |
1140 |
| - |
1141 |
| - |
1142 |
| -from .linfnorm_mimo_testcases import continuous_time_mimo, discrete_time_mimo |
1143 |
| - |
1144 |
| - |
1145 | 1104 | class TestLinfnorm:
|
1146 |
| - @slycotonly |
1147 |
| - # @pytest.mark.parametrize( |
1148 |
| - # "name, sys, refgpeak, reffpeak", |
1149 |
| - # [ |
1150 |
| - # ]) |
1151 |
| - def test_linfnorm_siso_continuoustime(self, continuous_time_siso): |
1152 |
| - sys, refgpeak, reffpeak = continuous_time_siso |
1153 |
| - gpeak, fpeak = linfnorm(sys) |
1154 |
| - np.testing.assert_allclose(gpeak, refgpeak) |
1155 |
| - np.testing.assert_allclose(fpeak, reffpeak) |
1156 |
| - |
| 1105 | + # these are simple tests; we assume ab13dd is correct |
| 1106 | + # python-control specific behaviour is: |
| 1107 | + # - checking for continuous- and discrete-time |
| 1108 | + # - scaling fpeak for discrete-time |
| 1109 | + # - handling static gains |
| 1110 | + |
| 1111 | + # the underdamped gpeak and fpeak are found from |
| 1112 | + # gpeak = 1/(2*zeta*(1-zeta**2)**0.5) |
| 1113 | + # fpeak = wn*(1-2*zeta**2)**0.5 |
| 1114 | + @pytest.fixture(params=[ |
| 1115 | + ('static', ct.tf, ([1.23],[1]), 1.23, 0), |
| 1116 | + ('underdamped', ct.tf, ([100],[1, 2*0.5*10, 100]), 1.1547005, 7.0710678), |
| 1117 | + ]) |
| 1118 | + def ct_siso(self, request): |
| 1119 | + name, systype, sysargs, refgpeak, reffpeak = request.param |
| 1120 | + return systype(*sysargs), refgpeak, reffpeak |
| 1121 | + |
| 1122 | + @pytest.fixture(params=[ |
| 1123 | + ('underdamped', ct.tf, ([100],[1, 2*0.5*10, 100]), 1e-4, 1.1547005, 7.0710678), |
| 1124 | + ]) |
| 1125 | + def dt_siso(self, request): |
| 1126 | + name, systype, sysargs, dt, refgpeak, reffpeak = request.param |
| 1127 | + return ct.c2d(systype(*sysargs), dt), refgpeak, reffpeak |
1157 | 1128 |
|
1158 | 1129 | @slycotonly
|
1159 |
| - def test_linfnorm_siso_discretetime(self, discrete_time_siso): |
1160 |
| - sys, refgpeak, reffpeak = discrete_time_siso |
| 1130 | + def test_linfnorm_ct_siso(self, ct_siso): |
| 1131 | + sys, refgpeak, reffpeak = ct_siso |
1161 | 1132 | gpeak, fpeak = linfnorm(sys)
|
1162 | 1133 | np.testing.assert_allclose(gpeak, refgpeak)
|
1163 | 1134 | np.testing.assert_allclose(fpeak, reffpeak)
|
1164 | 1135 |
|
1165 |
| - |
1166 | 1136 | @slycotonly
|
1167 |
| - def test_linfnorm_mimo_continuoustime(self, continuous_time_mimo): |
1168 |
| - sys, refgpeak, reffpeak = continuous_time_mimo |
| 1137 | + def test_linfnorm_dt_siso(self, dt_siso): |
| 1138 | + sys, refgpeak, reffpeak = dt_siso |
1169 | 1139 | gpeak, fpeak = linfnorm(sys)
|
| 1140 | + # c2d pole-mapping has round-off |
1170 | 1141 | np.testing.assert_allclose(gpeak, refgpeak)
|
1171 | 1142 | np.testing.assert_allclose(fpeak, reffpeak)
|
1172 | 1143 |
|
1173 | 1144 | @slycotonly
|
1174 |
| - def test_linfnorm_mimo_discretetime(self, discrete_time_mimo): |
1175 |
| - sys, refgpeak, reffpeak = discrete_time_mimo |
| 1145 | + def test_linfnorm_ct_mimo(self, ct_siso): |
| 1146 | + siso, refgpeak, reffpeak = ct_siso |
| 1147 | + sys = ct.append(siso, siso) |
1176 | 1148 | gpeak, fpeak = linfnorm(sys)
|
1177 | 1149 | np.testing.assert_allclose(gpeak, refgpeak)
|
1178 | 1150 | np.testing.assert_allclose(fpeak, reffpeak)
|
1179 |
| - |
1180 |
| - @slycotonly |
1181 |
| - def test_linfnorm_notimebase(self): |
1182 |
| - g = ct.ss(-0.1,1,1,0,dt=None) |
1183 |
| - with pytest.raises(ValueError): |
1184 |
| - linfnorm(g) |
0 commit comments