8000 Merge pull request #984 from murrayrm/fix_warnings-30Mar2024 · python-control/python-control@ea3e6a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit ea3e6a5

Browse files
authored
Merge pull request #984 from murrayrm/fix_warnings-30Mar2024
Fix warning messages in tests; update rlocus/pzmap limits
2 parents 7fd7243 + dea3821 commit ea3e6a5

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

control/pzmap.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def pole_zero_plot(
330330
if grid == 'empty':
331331
# Leave off grid entirely
332332
ax = plt.axes()
333-
xlim = ylim = [0, 0] # use data to set limits
333+
xlim = ylim = [np.inf, -np.inf] # use data to set limits
334334
else:
335335
# draw stability boundary; use first response timebase
336336
ax, fig = nogrid(data[0].dt, scaling=scaling)
@@ -574,7 +574,7 @@ def _compute_root_locus_limits(response):
574574
]
575575
ylim = max(0, np.max(response.sys.zeros().imag))
576576
else:
577-
xlim, ylim = [0, 0], 0
577+
xlim, ylim = [np.inf, -np.inf], 0
578578

579579
# Go through each locus and look for features
580580
rho = config._get_param('pzmap', 'buffer_factor')
@@ -603,6 +603,12 @@ def _compute_root_locus_limits(response):
603603
xlim[1] = rho * xlim[1] if xlim[1] > 0 else 0
604604
ylim = rho * ylim if ylim > 0 else np.max(np.abs(xlim))
605605

606+
# Make sure the limits make sense
607+
if xlim == [0, 0]:
608+
xlim = [-1, 1]
609+
if ylim == 0:
610+
ylim = 1
611+
606612
return xlim, [-ylim, ylim]
607613

608614

control/tests/rlocus_test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ def test_root_locus_documentation(savefigs=False):
186186
sys = ct.tf([1, 2], [1, 2, 3], name='SISO transfer function')
187187
response = ct.pole_zero_map(sys)
188188
ct.pole_zero_plot(response)
189-
plt.savefig('pzmap-siso_ctime-default.png')
189+
if savefigs:
190+
plt.savefig('pzmap-siso_ctime-default.png')
190191

191192
plt.figure()
192193
ct.root_locus_map(sys).plot()
193-
plt.savefig('rlocus-siso_ctime-default.png')
194+
if savefigs:
195+
plt.savefig('rlocus-siso_ctime-default.png')
194196

195197
# TODO: generate event in order to generate real title
196198
plt.figure()
@@ -200,18 +202,21 @@ def test_root_locus_documentation(savefigs=False):
200202
with plt.rc_context(freqplot_rcParams):
201203
ax.set_title(
202204
"Clicked at: -2.729+1.511j gain = 3.506 damping = 0.8748")
203-
plt.savefig('rlocus-siso_ctime-clicked.png')
205+
if savefigs:
206+
plt.savefig('rlocus-siso_ctime-clicked.png')
204207

205208
plt.figure()
206209
sysd = sys.sample(0.1)
207210
ct.root_locus_plot(sysd)
208-
plt.savefig('rlocus-siso_dtime-default.png')
211+
if savefigs:
212+
plt.savefig('rlocus-siso_dtime-default.png')
209213

210214
plt.figure()
211215
sys1 = ct.tf([1, 2], [1, 2, 3], name='sys1')
212216
sys2 = ct.tf([1, 0.2], [1, 1, 3, 1, 1], name='sys2')
213217
ct.root_locus_plot([sys1, sys2], grid=False)
214-
plt.savefig('rlocus-siso_multiple-nogrid.png')
218+
if savefigs:
219+
plt.savefig('rlocus-siso_multiple-nogrid.png')
215220

216221

217222
if __name__ == "__main__":

0 commit comments

Comments
 (0)
0