Skip to content

Commit abca69d

Browse files
committed
improved tvect test coverage
1 parent fc8f8d7 commit abca69d

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

control/tests/sisotool_test.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def sys221(self):
5050
D221 = [[1., -1.]]
5151
return StateSpace(A222, B222, C221, D221)
5252

53-
def test_sisotool(self, sys, sysdt, sys222, sys221):
53+
def test_sisotool(self, sys):
5454
sisotool(sys, Hz=False)
5555
fig = plt.gcf()
5656
ax_mag, ax_rlocus, ax_phase, ax_step = fig.axes[:4]
@@ -122,18 +122,46 @@ def test_sisotool(self, sys, sysdt, sys222, sys221):
122122
assert_array_almost_equal(
123123
ax_step.lines[0].get_data()[1][:10], step_response_moved, 4)
124124

125+
def test_sisotool_tvect(self, sys):
125126
# test supply tvect
126-
sisotool(sys, tvect=np.arange(0, 1, .1))
127+
tvect = np.linspace(0, 1, 10)
128+
sisotool(sys, tvect=tvect)
129+
fig = plt.gcf()
130+
ax_rlocus, ax_step = fig.axes[1], fig.axes[3]
131+
132+
# Move the rootlocus to another point and confirm same tvect
133+
event = type('test', (object,), {'xdata': 2.31206868287,
134+
'ydata': 15.5983051046,
135+
'inaxes': ax_rlocus.axes})()
136+
_RLClickDispatcher(event=event, sys=sys, fig=fig,
137+
ax_rlocus=ax_rlocus, sisotool=True, plotstr='-',
138+
bode_plot_params=dict(), tvect=tvect)
139+
assert_array_almost_equal(tvect, ax_step.lines[0].get_data()[0])
140+
141+
def test_sisotool_tvect_dt(self, sysdt):
142+
# test supply tvect
143+
tvect = np.linspace(0, 1, 10)
144+
sisotool(sysdt, tvect=tvect)
145+
fig = plt.gcf()
146+
ax_rlocus, ax_step = fig.axes[1], fig.axes[3]
127147

128-
# test discrete-time
129-
sisotool(sysdt, tvect=5)
148+
# Move the rootlocus to another point and confirm same tvect
149+
event = type('test', (object,), {'xdata': 2.31206868287,
150+
'ydata': 15.5983051046,
151+
'inaxes': ax_rlocus.axes})()
152+
_RLClickDispatcher(event=event, sys=sysdt, fig=fig,
153+
ax_rlocus=ax_rlocus, sisotool=True, plotstr='-',
154+
bode_plot_params=dict(), tvect=tvect)
155+
assert_array_almost_equal(tvect, ax_step.lines[0].get_data()[0])
130156

131-
# test MIMO compatibility
132-
# sys must be siso or 2 input, 2 output
157+
def test_sisotool_mimo(self, sys222, sys221):
158+
# a 2x2 should not raise an error:
159+
sisotool(sys222)
160+
161+
# but 2 input, 1 output should
133162
with pytest.raises(ControlMIMONotImplemented):
134163
sisotool(sys221)
135-
# does not raise an error:
136-
sisotool(sys222)
164+
137165

138166

139167

0 commit comments

Comments
 (0)
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