@@ -17,14 +17,10 @@ class TestSisotool:
1717 """These are tests for the sisotool in sisotool.py."""
1818
1919 @pytest .fixture
20- def sys (self ):
20+ def tsys (self , request ):
2121 """Return a generic SISO transfer function"""
22- return TransferFunction ([1000 ], [1 , 25 , 100 , 0 ])
23-
24- @pytest .fixture
25- def sysdt (self ):
26- """Return a generic SISO transfer function"""
27- return TransferFunction ([1000 ], [1 , 25 , 100 , 0 ], True )
22+ dt = getattr (request , 'param' , 0 )
23+ return TransferFunction ([1000 ], [1 , 25 , 100 , 0 ], dt )
2824
2925 @pytest .fixture
3026 def sys222 (self ):
@@ -50,8 +46,8 @@ def sys221(self):
5046 D221 = [[1. , - 1. ]]
5147 return StateSpace (A222 , B222 , C221 , D221 )
5248
53- def test_sisotool (self , sys ):
54- sisotool (sys , Hz = False )
49+ def test_sisotool (self , tsys ):
50+ sisotool (tsys , Hz = False )
5551 fig = plt .gcf ()
5652 ax_mag , ax_rlocus , ax_phase , ax_step = fig .axes [:4 ]
5753
@@ -89,7 +85,7 @@ def test_sisotool(self, sys):
8985 event = type ('test' , (object ,), {'xdata' : 2.31206868287 ,
9086 'ydata' : 15.5983051046 ,
9187 'inaxes' : ax_rlocus .axes })()
92- _RLClickDispatcher (event = event , sys = sys , fig = fig ,
88+ _RLClickDispatcher (event = event , sys = tsys , fig = fig ,
9389 ax_rlocus = ax_rlocus , sisotool = True , plotstr = '-' ,
9490 bode_plot_params = bode_plot_params , tvect = None )
9591
@@ -118,37 +114,24 @@ def test_sisotool(self, sys):
118114 assert_array_almost_equal (
119115 ax_step .lines [0 ].get_data ()[1 ][:10 ], step_response_moved , 4 )
120116
121- def test_sisotool_tvect (self , sys ):
117+ @pytest .mark .parametrize ('tsys' , [0 , True ],
118+ indirect = True , ids = ['ctime' , 'dtime' ])
119+ def test_sisotool_tvect (self , tsys ):
122120 # test supply tvect
123121 tvect = np .linspace (0 , 1 , 10 )
124- sisotool (sys , tvect = tvect )
122+ sisotool (tsys , tvect = tvect )
125123 fig = plt .gcf ()
126124 ax_rlocus , ax_step = fig .axes [1 ], fig .axes [3 ]
127125
128126 # Move the rootlocus to another point and confirm same tvect
129127 event = type ('test' , (object ,), {'xdata' : 2.31206868287 ,
130128 'ydata' : 15.5983051046 ,
131129 'inaxes' : ax_rlocus .axes })()
132- _RLClickDispatcher (event = event , sys = sys , fig = fig ,
130+ _RLClickDispatcher (event = event , sys = tsys , fig = fig ,
133131 ax_rlocus = ax_rlocus , sisotool = True , plotstr = '-' ,
134132 bode_plot_params = dict (), tvect = tvect )
135133 assert_array_almost_equal (tvect , ax_step .lines [0 ].get_data ()[0 ])
136134
137- def test_sisotool_tvect_dt (self , sysdt ):
138- # test supply tvect
139- tvect = np .linspace (0 , 1 , 10 )
140- sisotool (sysdt , tvect = tvect )
141- fig = plt .gcf ()
142- ax_rlocus , ax_step = fig .axes [1 ], fig .axes [3 ]
143-
144- # Move the rootlocus to another point and confirm same tvect
145- event = type ('test' , (object ,), {'xdata' : 2.31206868287 ,
146- 'ydata' : 15.5983051046 ,
147- 'inaxes' : ax_rlocus .axes })()
148- _RLClickDispatcher (event = event , sys = sysdt , fig = fig ,
149- ax_rlocus = ax_rlocus , sisotool = True , plotstr = '-' ,
150- bode_plot_params = dict (), tvect = tvect )
151- assert_array_almost_equal (tvect , ax_step .lines [0 ].get_data ()[0 ])
152135
153136 def test_sisotool_mimo (self , sys222 , sys221 ):
154137 # a 2x2 should not raise an error:
0 commit comments