Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,10 @@ def _convertToStateSpace(sys, **kw):
ssout[3][:sys.outputs, :states],
ssout[4], sys.dt)
except ImportError:
# If slycot is not available, use signal.lti (SISO only)
if (sys.inputs != 1 or sys.outputs != 1):
raise TypeError("No support for MIMO without slycot")

# TODO: do we want to squeeze first and check dimenations?
# I think this will fail if num and den aren't 1-D after
# the squeeze
Expand Down
23 changes: 23 additions & 0 deletions control/tests/convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ def testConvert(self):
np.testing.assert_array_almost_equal( \
ssorig_imag, tfxfrm_imag)

def testConvertMIMO(self):
"""Test state space to transfer function conversion."""
verbose = self.debug

# Do a MIMO conversation and make sure that it is processed
# correctly both with and without slycot
#
# Example from issue #120, jgoppert
import control

# Set up a transfer function (should always work)
tfcn = control.tf([[[-235, 1.146e4],
[-235, 1.146E4],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation here and on the next 4 lines seems to be slightly off. I recommend

        tfcn = control.tf([[[-235, 1.146e4],
                            [-235, 1.146E4],
                            [-235, 1.146E4, 0]]],
                          [[[1, 48.78, 0],
                            [1, 48.78, 0, 0],
                            [0.008, 1.39, 48.78]]])

[-235, 1.146E4, 0]]],
[[[1, 48.78, 0],
[1, 48.78, 0, 0],
[0.008, 1.39, 48.78]]])

# Convert to state space and look for an error
if (not slycot_check()):
self.assertRaises(TypeError, control.tf2ss, tfcn)


def suite():
return unittest.TestLoader().loadTestsFromTestCase(TestConvert)

Expand Down