@@ -1102,48 +1102,62 @@ def test_latex_repr_testsize(editsdefaults):
1102
1102
assert gstatic ._repr_latex_ () is None
1103
1103
1104
1104
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
+
1105
1145
class TestLinfnorm :
1106
- # these are relatively simple examples
1107
- # the underdamped gpeak and fpeak are found from
1108
- # gpeak = 1/(2*zeta*(1-zeta**2)**0.5
1109
- # fpeak = wn*(1-2*zeta**2)**0.5
1110
1146
@slycotonly
1111
- @pytest .mark .parametrize (
1112
- "name, sys, refgpeak, reffpeak" ,
1113
- [
1114
- ('lpf' , ct .tf ([1 ],[1 ,1 ]), 1 , 0 ),
1115
- ('static' , ct .tf ([1.23 ],[1 ]), 1.23 , 0 ),
1116
- ('underdamped' , ct .tf ([100 ],[1 , 2 * 0.1 * 10 , 100 ]), 5.02518907629606 , 9.89949493661 ),
1117
- ('hpf' , ct .tf ([1 , 0 ], [1 , 1 ]), 1 , np .inf ),
1118
- ('integrator' , ct .tf ([1 ],[1 ,0 ]), np .inf , 0 ),
1119
- ('undamped' , ct .tf ([1 ],[1 , 0 , 144 ]), np .inf , 12 ),
1120
- ('zero' , ct .tf ([0 ],[1 , 0 , 144 ]), 0 , 0 ),
1121
- ])
1122
- def test_linfnorm_siso_continuoustime (self , name , sys , refgpeak , reffpeak ):
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
1123
1153
gpeak , fpeak = linfnorm (sys )
1124
1154
np .testing .assert_allclose (gpeak , refgpeak )
1125
1155
np .testing .assert_allclose (fpeak , reffpeak )
1126
1156
1127
1157
1128
- # these are the continuous-time examples with some tweaks
1129
1158
@slycotonly
1130
- @pytest .mark .parametrize (
1131
- "name, sys, refgpeak, reffpeak" ,
1132
- [
1133
- ('lpf' , ct .c2d (ct .tf ([1 ],[1 ,1 ]), 0.1 ), 1 , 0 ),
1134
- ('static' , ct .c2d (ct .tf ([1.23 ],[1 ]), 0.1 ), 1.23 , 0 ),
1135
- # the gain and frequency don't quite match the continuous-time case,
1136
- # I assume due to c2d imperfection
1137
- ('underdamped' , ct .c2d (ct .tf ([100 ],[1 , 2 * 0.1 * 10 , 100 ]), 0.01 ), 5.023137 , 9.899412 ),
1138
- # The HPF fpeak is the Nyquist frequency
1139
- # Assume gpeak mismatch is again c2d mismatch
1140
- ('hpf' , ct .c2d (ct .tf ([1 , 0 ], [1 , 1 ]), 0.1 ), 1.04995845 , np .pi * 10 ),
1141
- ('integrator' , ct .c2d (ct .tf ([1 ],[1 ,0 ]), 0.1 ), np .inf , 0 ),
1142
- ('undamped' , ct .c2d (ct .tf ([1 ],[1 , 0 , 144 ]), 0.003 ), np .inf , 12 ),
1143
- # ss call works around Scipy's "Badly conditioned filter coefficients" warning
1144
- ('zero' , ct .c2d (ct .ss (ct .tf ([0 ],[1 , 0 , 144 ])), 0.003 ), 0 , 0 ),
1145
- ])
1146
- def test_linfnorm_siso_discretetime (self , name , sys , refgpeak , reffpeak ):
1159
+ def test_linfnorm_siso_discretetime (self , discrete_time_siso ):
1160
+ sys , refgpeak , reffpeak = discrete_time_siso
1147
1161
gpeak , fpeak = linfnorm (sys )
1148
1162
np .testing .assert_allclose (gpeak , refgpeak )
1149
1163
np .testing .assert_allclose (fpeak , reffpeak )
0 commit comments