Skip to content

Commit ad33109

Browse files
committed
keep warnings clean + update impulse() default input to None
1 parent 4ec6377 commit ad33109

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

control/tests/timeresp_test.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ def test_squeeze(self, fcn, nstate, nout, ninp, squeeze, shape):
728728
"requires slycot.")
729729
else:
730730
sys = fcn(ct.rss(nstate, nout, ninp, strictly_proper=True))
731+
732+
# Keep track of expect users warnings
733+
warntype = UserWarning if sys.inputs > 1 else None
731734

732735
# Compute the length of the frequency array
733736
tvec = np.linspace(0, 1, 8)
@@ -736,13 +739,15 @@ def test_squeeze(self, fcn, nstate, nout, ninp, squeeze, shape):
736739
np.reshape(np.sin(tvec), (1, 8)))
737740

738741
# Pass squeeze argument and make sure the shape is correct
739-
_, yvec = ct.impulse_response(sys, tvec, squeeze=squeeze)
742+
with pytest.warns(warntype, match="Converting MIMO system"):
743+
_, yvec = ct.impulse_response(sys, tvec, squeeze=squeeze)
740744
assert yvec.shape == shape
741745

742746
_, yvec = ct.initial_response(sys, tvec, 1, squeeze=squeeze)
743747
assert yvec.shape == shape
744748

745-
_, yvec = ct.step_response(sys, tvec, squeeze=squeeze)
749+
with pytest.warns(warntype, match="Converting MIMO system"):
750+
_, yvec = ct.step_response(sys, tvec, squeeze=squeeze)
746751
assert yvec.shape == shape
747752

748753
_, yvec, xvec = ct.forced_response(
@@ -772,13 +777,15 @@ def test_squeeze(self, fcn, nstate, nout, ninp, squeeze, shape):
772777
ct.config.set_defaults('control', squeeze=False)
773778

774779
# Pass squeeze argument and make sure the shape is correct
775-
_, yvec = ct.impulse_response(sys, tvec)
780+
with pytest.warns(warntype, match="Converting MIMO system"):
781+
_, yvec = ct.impulse_response(sys, tvec)
776782
assert yvec.shape == (sys.outputs, 8)
777783

778784
_, yvec = ct.initial_response(sys, tvec, 1)
779785
assert yvec.shape == (sys.outputs, 8)
780786

781-
_, yvec = ct.step_response(sys, tvec)
787+
with pytest.warns(warntype, match="Converting MIMO system"):
788+
_, yvec = ct.step_response(sys, tvec)
782789
assert yvec.shape == (sys.outputs, 8)
783790

784791
_, yvec, xvec = ct.forced_response(

control/timeresp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ def initial_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
737737
return T, yout
738738

739739

740-
def impulse_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
740+
def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
741741
transpose=False, return_x=False, squeeze=None):
742742
# pylint: disable=W0622
743743
"""Impulse response of a linear system

0 commit comments

Comments
 (0)