1616from control .statesp import StateSpace
1717from control .xferfcn import TransferFunction
1818from control .matlab import ss , tf , bode , rss
19- from control .freqplot import bode_plot , nyquist_plot , singular_values_plot
19+ from control .freqplot import bode_plot , nyquist_plot , nyquist_response , \
20+ singular_values_plot , singular_values_response
2021from control .tests .conftest import slycotonly
2122
2223pytestmark = pytest .mark .usefixtures ("mplcleanup" )
@@ -97,19 +98,17 @@ def test_nyquist_basic(ss_siso):
9798 tf_siso = tf (ss_siso )
9899 nyquist_plot (ss_siso )
99100 nyquist_plot (tf_siso )
100- count , contour = nyquist_plot (
101- tf_siso , plot = False , return_contour = True , omega_num = 20 )
102- assert len (contour ) == 20
101+ response = nyquist_response (tf_siso , omega_num = 20 )
102+ assert len (response .contour ) == 20
103103
104104 with pytest .warns (UserWarning , match = "encirclements was a non-integer" ):
105105 count , contour = nyquist_plot (
106106 tf_siso , plot = False , omega_limits = (1 , 100 ), return_contour = True )
107107 assert_allclose (contour [0 ], 1j )
108108 assert_allclose (contour [- 1 ], 100j )
109109
110- count , contour = nyquist_plot (
111- tf_siso , plot = False , omega = np .logspace (- 1 , 1 , 10 ), return_contour = True )
112- assert len (contour ) == 10
110+ response = nyquist_response (tf_siso , omega = np .logspace (- 1 , 1 , 10 ))
111+ assert len (response .contour ) == 10
113112
114113
115114@pytest .mark .usefixtures ("legacy_plot_signature" )
@@ -200,7 +199,7 @@ def test_bode_margin(dB, maginfty1, maginfty2, gminv,
200199 den = [1 , 25 , 100 , 0 ]
201200 sys = ctrl .tf (num , den )
202201 plt .figure ()
203- ctrl .bode_plot (sys , margins = True , dB = dB , deg = deg , Hz = Hz )
202+ ctrl .bode_plot (sys , display_margins = True , dB = dB , deg = deg , Hz = Hz )
204203 fig = plt .gcf ()
205204 allaxes = fig .get_axes ()
206205
@@ -655,21 +654,22 @@ def tsystem(request, ss_mimo_ct, ss_miso_ct, ss_simo_ct, ss_siso_ct, ss_mimo_dt)
655654def test_singular_values_plot (tsystem ):
656655 sys = tsystem .sys
657656 for omega_ref , sigma_ref in zip (tsystem .omegas , tsystem .sigmas ):
658- sigma , _ = singular_values_plot (sys , omega_ref , plot = False )
657+ response = singular_values_response (sys , omega_ref )
658+ sigma = np .real (response .fresp [:, 0 , :])
659659 np .testing .assert_almost_equal (sigma , sigma_ref )
660660
661661
662662def test_singular_values_plot_mpl_base (ss_mimo_ct , ss_mimo_dt ):
663663 sys_ct = ss_mimo_ct .sys
664664 sys_dt = ss_mimo_dt .sys
665665 plt .figure ()
666- singular_values_plot (sys_ct , plot = True )
666+ singular_values_plot (sys_ct )
667667 fig = plt .gcf ()
668668 allaxes = fig .get_axes ()
669669 assert (len (allaxes ) == 1 )
670670 assert (allaxes [0 ].get_label () == 'control-sigma' )
671671 plt .figure ()
672- singular_values_plot ([sys_ct , sys_dt ], plot = True , Hz = True , dB = True , grid = False )
672+ singular_values_plot ([sys_ct , sys_dt ], Hz = True , dB = True , grid = False )
673673 fig = plt .gcf ()
674674 allaxes = fig .get_axes ()
675675 assert (len (allaxes ) == 1 )
@@ -679,10 +679,10 @@ def test_singular_values_plot_mpl_base(ss_mimo_ct, ss_mimo_dt):
679679def test_singular_values_plot_mpl_superimpose_nyq (ss_mimo_ct , ss_mimo_dt ):
680680 sys_ct = ss_mimo_ct .sys
681681 sys_dt = ss_mimo_dt .sys
682- omega_all = np .logspace (- 3 , 2 , 1000 )
682+ omega_all = np .logspace (- 3 , int ( math . log10 ( 2 * math . pi / sys_dt . dt )) , 1000 )
683683 plt .figure ()
684- singular_values_plot (sys_ct , omega_all , plot = True )
685- singular_values_plot (sys_dt , omega_all , plot = True )
684+ singular_values_plot (sys_ct , omega_all )
685+ singular_values_plot (sys_dt , omega_all )
686686 fig = plt .gcf ()
687687 allaxes = fig .get_axes ()
688688 assert (len (allaxes ) == 1 )
0 commit comments