10000 Add zero-norm cases for linfnorm tests. · python-control/python-control@af5326a · GitHub
[go: up one dir, main page]

Skip to content

Commit af5326a

Browse files
committed
Add zero-norm cases for linfnorm tests.
1 parent f4761f1 commit af5326a

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

control/tests/linfnorm_mimo_testcases.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,23 @@
8787
[ -2., 11., 4.]]),
8888
inf,
8989
57.20000000000001),
90-
('gstatic', StateSpace([],[],[],[[-0.,-1., 1.]]), 1.4142135623730951, 0)]
90+
('gstatic', StateSpace([],[],[],[[-0.,-1., 1.]]), 1.4142135623730951, 0),
91+
('gzero',
92+
StateSpace([[ 5., -4.,-21., -6.],
93+
[ -7., -7., 3.,-21.],
94+
[ -5.,-14.,-13., -5.],
95+
[ 5., -1., 13., 12.]],[[12.,-6., 1.],
96+
[-2., 8.,-9.],
97+
[ 2.,-8.,-9.],
98+
[ 9., 3.,12.]],[[0.,0.,0.,0.],
99+
[0.,0.,0.,0.],
100+
[0.,0.,0.,0.],
101+
[0.,0.,0.,0.]],[[0.,0.,0.],
102+
[0.,0.,0.],
103+
[0.,0.,0.],
104+
[0.,0.,0.]]),
105+
0.0,
106+
0.0)]
91107

92108
discrete_time = [('gdamped',
93109
StateSpace([[0.9819824738582276 ,0.04738017085285391,0.01304472802238469,
@@ -189,4 +205,24 @@
189205
[ -2., 11., 4.]],0.001748251748251748),
190206
inf,
191207
57.19999999999999),
192-
('gstatic', StateSpace([],[],[],[[-0.,-1., 1.]],0.1), 1.4142135623730951, 0)]
208+
('gstatic', StateSpace([],[],[],[[-0.,-1., 1.]],0.1), 1.4142135623730951, 0),
209+
('gzero',
210+
StateSpace([[ 1.0303043647406893 ,-0.01781959428593542,-0.11765779072192348,
211+
-0.03276338055744957],
212+
[-0.04132960349200208, 0.9613575174517476 , 0.014113316237035 ,
213+
-0.12012463024982983],
214+
[-0.02651156643544365,-0.07450916625348535, 0.9291146760911255 ,
215+
-0.02314667550730827],
216+
[ 0.02880868304806791,-0.00888795026944078, 0.07167878230045487,
217+
1.0692080208974695 ]],[[ 0.06752200650981538,-0.03251013768460283, 0.00811951955333441],
218+
[-0.01544640323794919, 0.04373088794929778,-0.05450868314870591],
219+
[ 0.00979057789642909,-0.0451257463241516 ,-0.04809300103945695],
220+
[ 0.05411465844610203, 0.01526286520259314, 0.06869084817801113]],[[0.,0.,0.,0.],
221+
[0.,0.,0.,0.],
222+
[0.,0.,0.,0.],
223+
[0.,0.,0.,0.]],[[0.,0.,0.],
224+
[0.,0.,0.],
225+
[0.,0.,0.],
226+
[0.,0.,0.]],0.0056597835333160335),
227+
0.0,
228+
0.0)]

control/tests/statesp_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ def test_latex_repr_testsize(editsdefaults):
11151115
('hpf', ct.tf([1, 0], [1, 1]), 1, np.inf),
11161116
('integrator', ct.tf([1],[1,0]), np.inf, 0),
11171117
('undamped', ct.tf([1],[1, 0, 144]), np.inf, 12),
1118+
('zero', ct.tf([0],[1, 0, 144]), 0, 0),
11181119
])
11191120
def test_linfnorm_siso_continuoustime(name, sys, refgpeak, reffpeak):
11201121
gpeak, fpeak = linfnorm(sys)
@@ -1136,6 +1137,8 @@ def test_linfnorm_siso_continuoustime(name, sys, refgpeak, reffpeak):
11361137
('hpf', ct.c2d(ct.tf([1, 0], [1, 1]), 0.1), 1.04995845, np.pi * 10),
11371138
('integrator', ct.c2d(ct.tf([1],[1,0]), 0.1), np.inf, 0),
11381139
('undamped', ct.c2d(ct.tf([1],[1, 0, 144]), 0.003), np.inf, 12),
1140+
# ss call works around Scipy's "Badly conditioned filter coefficients" warning
1141+
('zero', ct.c2d(ct.ss(ct.tf([0],[1, 0, 144])), 0.003), 0, 0),
11391142
])
11401143
def test_linfnorm_siso_discretetime(name, sys, refgpeak, reffpeak):
11411144
gpeak, fpeak = linfnorm(sys)

tools/make_linfnorm_mimo_testcases.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ def ss_repr(g):
238238
gstatic = ct.ss([], [], [], randnormint(3,3), dt=0)
239239
normstatic, freqstatic = ct.linfnorm(gstatic)
240240

241+
gzero = randsys(nx, nu, ny)
242+
gzero.C[...] = 0
243+
gzero.D[...] = 0
244+
normzero, freqzero = ct.linfnorm(gzero)
245+
241246
# dict: of name -> continuous-time example
242247
ct_ex = {
243248
'gdamped' : (gdamped, normdamped, freqdamped),
@@ -246,6 +251,7 @@ def ss_repr(g):
246251
'gunder' : (gunder, normunder, frequnder),
247252
'gun' : (gun, normun, frequn),
248253
'gstatic' : (gstatic, normstatic, freqstatic),
254+
'gzero' : (gzero, normzero, freqzero),
249255
}
250256

251257
# dict: name -> discrete-time example
@@ -284,6 +290,9 @@ def show_norm(g, gpeak, fpeak, ax):
284290
show_norm(*dt_ex[name], ax[1])
285291
fig.suptitle(name)
286292
fig.tight_layout()
293+
# for PRs etc
294+
# fig.savefig(f'{name}.png')
295+
287296
print('Review plots for correctness!')
288297
plt.show()
289298

0 commit comments

Comments
 (0)
0