99# Step responses
1010@pytest .mark .parametrize ("nin, nout" , [(1 , 1 ), (1 , 2 ), (2 , 1 ), (2 , 2 ), (2 , 3 )])
1111@pytest .mark .parametrize ("transpose" , [True , False ])
12- @pytest .mark .parametrize ("plot_inputs" , [None , True , False ])
12+ @pytest .mark .parametrize ("plot_inputs" , [None , True , False , 'overlay' ])
1313def test_simple_response (nout , nin , transpose , plot_inputs ):
1414 sys = ct .rss (4 , nout , nin )
1515 stepresp = ct .step_response (sys )
1616 stepresp .plot (plot_inputs = plot_inputs , transpose = transpose )
1717
1818 # Add additional data (and provide infon in the title)
19- ct .step_response ( ct . rss (4 , nout , nin ), stepresp . time [ - 1 ]). plot (
20- plot_inputs = plot_inputs , transpose = transpose ,
21- title = stepresp . title + f" [ { plot_inputs = } , { transpose = } ]" )
19+ newsys = ct .rss (4 , nout , nin )
20+ out = ct . step_response ( newsys , stepresp . time [ - 1 ]). plot (
21+ plot_inputs = plot_inputs , transpose = transpose )
2222
23+ # Update the title so we can see what is going on
24+ fig = out [0 , 0 ][0 ].axes .figure
25+ fig .suptitle (
26+ fig ._suptitle ._text + f" [{ nout } x{ nin } , { plot_inputs = } , { transpose = } ]" ,
27+ fontsize = 'small' )
2328
2429@pytest .mark .parametrize ("transpose" , [True , False ])
2530def test_combine_signals (transpose ):
@@ -49,6 +54,19 @@ def test_combine_signals_traces(transpose):
4954 f"transpose={ transpose } " )
5055
5156
57+ def test_errors ():
58+ sys = ct .rss (2 , 1 , 1 )
59+ stepresp = ct .step_response (sys )
60+ with pytest .raises (TypeError , match = "unrecognized keyword" ):
61+ stepresp .plot (unknown = None )
62+
63+ with pytest .raises (TypeError , match = "unrecognized keyword" ):
64+ ct .ioresp_plot (stepresp , unknown = None )
65+
66+ with pytest .raises (ValueError , match = "unrecognized value" ):
67+ stepresp .plot (plot_inputs = 'unknown' )
68+
69+
5270if __name__ == "__main__" :
5371 #
5472 # Interactive mode: generate plots for manual viewing
@@ -66,7 +84,7 @@ def test_combine_signals_traces(transpose):
6684 print ("Simple step responses" )
6785 for size in [(1 , 1 ), (1 , 2 ), (2 , 1 ), (2 , 2 ), (2 , 3 )]:
6886 for transpose in [False , True ]:
69- for plot_inputs in [None , True , False ]:
87+ for plot_inputs in [None , True , False , 'overlay' ]:
7088 plt .figure ()
7189 test_simple_response (
7290 * size , transpose = transpose , plot_inputs = plot_inputs )
0 commit comments