From dea3821e5f49ff1db4a43436f48787cabfaf7500 Mon Sep 17 00:00:00 2001 From: Richard Murray Date: Sat, 30 Mar 2024 16:23:08 -0700 Subject: [PATCH] fix warning messags in tests; update rlocus/pzmap limits --- control/pzmap.py | 10 ++++++++-- control/tests/rlocus_test.py | 15 ++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/control/pzmap.py b/control/pzmap.py index a1f71da1f..d7662d1d9 100644 --- a/control/pzmap.py +++ b/control/pzmap.py @@ -330,7 +330,7 @@ def pole_zero_plot( if grid == 'empty': # Leave off grid entirely ax = plt.axes() - xlim = ylim = [0, 0] # use data to set limits + xlim = ylim = [np.inf, -np.inf] # use data to set limits else: # draw stability boundary; use first response timebase ax, fig = nogrid(data[0].dt, scaling=scaling) @@ -574,7 +574,7 @@ def _compute_root_locus_limits(response): ] ylim = max(0, np.max(response.sys.zeros().imag)) else: - xlim, ylim = [0, 0], 0 + xlim, ylim = [np.inf, -np.inf], 0 # Go through each locus and look for features rho = config._get_param('pzmap', 'buffer_factor') @@ -603,6 +603,12 @@ def _compute_root_locus_limits(response): xlim[1] = rho * xlim[1] if xlim[1] > 0 else 0 ylim = rho * ylim if ylim > 0 else np.max(np.abs(xlim)) + # Make sure the limits make sense + if xlim == [0, 0]: + xlim = [-1, 1] + if ylim == 0: + ylim = 1 + return xlim, [-ylim, ylim] diff --git a/control/tests/rlocus_test.py b/control/tests/rlocus_test.py index 5ee2830c9..5511f5b82 100644 --- a/control/tests/rlocus_test.py +++ b/control/tests/rlocus_test.py @@ -186,11 +186,13 @@ def test_root_locus_documentation(savefigs=False): sys = ct.tf([1, 2], [1, 2, 3], name='SISO transfer function') response = ct.pole_zero_map(sys) ct.pole_zero_plot(response) - plt.savefig('pzmap-siso_ctime-default.png') + if savefigs: + plt.savefig('pzmap-siso_ctime-default.png') plt.figure() ct.root_locus_map(sys).plot() - plt.savefig('rlocus-siso_ctime-default.png') + if savefigs: + plt.savefig('rlocus-siso_ctime-default.png') # TODO: generate event in order to generate real title plt.figure() @@ -200,18 +202,21 @@ def test_root_locus_documentation(savefigs=False): with plt.rc_context(freqplot_rcParams): ax.set_title( "Clicked at: -2.729+1.511j gain = 3.506 damping = 0.8748") - plt.savefig('rlocus-siso_ctime-clicked.png') + if savefigs: + plt.savefig('rlocus-siso_ctime-clicked.png') plt.figure() sysd = sys.sample(0.1) ct.root_locus_plot(sysd) - plt.savefig('rlocus-siso_dtime-default.png') + if savefigs: + plt.savefig('rlocus-siso_dtime-default.png') plt.figure() sys1 = ct.tf([1, 2], [1, 2, 3], name='sys1') sys2 = ct.tf([1, 0.2], [1, 1, 3, 1, 1], name='sys2') ct.root_locus_plot([sys1, sys2], grid=False) - plt.savefig('rlocus-siso_multiple-nogrid.png') + if savefigs: + plt.savefig('rlocus-siso_multiple-nogrid.png') if __name__ == "__main__": pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy