8000 updated MIMO not implemented w/ unit test, per @sawyerbfuller · python-control/python-control@31793e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31793e6

Browse files
committed
updated MIMO not implemented w/ unit test, per @sawyerbfuller
1 parent 2580d18 commit 31793e6

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

control/statesp.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
from scipy.signal import StateSpace as signalStateSpace
6161
from warnings import warn
6262

63-
from .exception import ControlSlycot, slycot_check
63+
from .exception import ControlSlycot, slycot_check, ControlMIMONotImplemented
6464
from .frdata import FrequencyResponseData
6565
from .lti import LTI, _process_frequency_response
66-
from .iosys import InputOutputSystem, common_timebase, isdtime, \
66+
from .iosys import InputOutputSystem, common_timebase, isdtime, issiso, \
6767
_process_iosys_keywords, _process_dt_keyword, _process_signal_list
6868
from .nlsys import NonlinearIOSystem, InterconnectedSystem
6969
from . import config
@@ -2268,8 +2268,9 @@ def _convert_to_statespace(sys, use_prefix_suffix=False, method=None):
22682268
D[i, j] = sys.num[i][j][0] / sys.den[i][j][0]
22692269
newsys = StateSpace([], [], [], D, sys.dt)
22702270
else:
2271-
if sys.ninputs != 1 or sys.noutputs != 1:
2272-
raise TypeError("No support for MIMO without slycot")
2271+
if not issiso(sys):
2272+
raise ControlMIMONotImplemented(
2273+
"MIMO system conversion not supported without Slycot")
22732274

22742275
A, B, C, D = \
22752276
sp.signal.tf2ss(squeeze(sys.num), squeeze(sys.den))

control/tests/convert_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from control import rss, ss, ss2tf, tf, tf2ss
2222
from control.statefbk import ctrb, obsv
2323
from control.freqplot import bode
24-
from control.exception import slycot_check
24+
from control.exception import slycot_check, ControlMIMONotImplemented
2525
from control.tests.conftest import slycotonly
2626

2727

@@ -167,7 +167,7 @@ def testConvertMIMO(self):
167167

168168
# Convert to state space and look for an error
169169
if (not slycot_check()):
170-
with pytest.raises(TypeError):
170+
with pytest.raises(ControlMIMONotImplemented):
171171
tf2ss(tsys)
172172
else:
173173
ssys = tf2ss(tsys)

control/tests/statesp_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,3 +1237,15 @@ def test_tf2ss_unstable(method):
12371237
tf_poles = np.sort(tf_sys.poles())
12381238
ss_poles = np.sort(ss_sys.poles())
12391239
np.testing.assert_allclose(tf_poles, ss_poles, rtol=1e-4)
1240+
1241+
1242+
def test_tf2ss_mimo():
1243+
sys_tf = ct.tf([[[1], [1, 1, 1]]], [[[1, 1, 1], [1, 2, 1]]])
1244+
1245+
if ct.slycot_check():
1246+
sys_ss = ct.ss(sys_tf)
1247+
np.testing.assert_allclose(
1248+
np.sort(sys_tf.poles()), np.sort(sys_ss.poles()))
1249+
else:
1250+
with pytest.raises(ct.ControlMIMONotImplemented):
1251+
sys_ss = ct.ss(sys_tf)

0 commit comments

Comments
 (0)
0