Skip to content

Commit c90a399

Browse files
committed
added code to check for MIMO in statesp._convertToStateSpace + unit test; address issue #120
1 parent cab850a commit c90a399

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

control/statesp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ def _convertToStateSpace(sys, **kw):
667667
ssout[3][:sys.outputs, :states],
668668
ssout[4], sys.dt)
669669
except ImportError:
670+
# If slycot is not available, use signal.lti (SISO only)
671+
if (sys.inputs != 1 or sys.outputs != 1):
672+
raise TypeError("No support for MIMO without slycot")
673+
670674
# TODO: do we want to squeeze first and check dimenations?
671675
# I think this will fail if num and den aren't 1-D after
672676
# the squeeze

control/tests/convert_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ def testConvert(self):
162162
np.testing.assert_array_almost_equal( \
163163
ssorig_imag, tfxfrm_imag)
164164

165+
def testConvertMIMO(self):
166+
"""Test state space to transfer function conversion."""
167+
verbose = self.debug
168+
169+
# Do a MIMO conversation and make sure that it is processed
170+
# correctly both with and without slycot
171+
#
172+
# Example from issue #120, jgoppert
173+
import control
174+
175+
# Set up a transfer function (should always work)
176+
tfcn = control.tf([[[-235, 1.146e4],
177+
[-235, 1.146E4],
178+
[-235, 1.146E4, 0]]],
179+
[[[1, 48.78, 0],
180+
[1, 48.78, 0, 0],
181+
[0.008, 1.39, 48.78]]])
182+
183+
# Convert to state space and look for an error
184+
if (not slycot_check()):
185+
self.assertRaises(TypeError, control.tf2ss, tfcn)
186+
187+
165188
def suite():
166189
return unittest.TestLoader().loadTestsFromTestCase(TestConvert)
167190

0 commit comments

Comments
 (0)