Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,7 @@ def _ssmatrix(data, axis=1, square=None, rows=None, cols=None, name=None):

Returns
-------
arr : 2D array, with shape (0, 0) if a is empty
arr : 2D array, with shape (0, 0) for empty vectors or matrices

"""
# Process the name of the object, if available
Expand All @@ -2310,9 +2310,9 @@ def _ssmatrix(data, axis=1, square=None, rows=None, cols=None, name=None):
if (ndim > 2):
raise ValueError(f"state-space matrix{name} must be 2-dimensional")

elif (ndim == 2 and shape == (1, 0)) or \
(ndim == 1 and shape == (0, )):
# Passed an empty matrix or empty vector; change shape to (0, 0)
elif (ndim == 2 and shape == (0, 0)) or \
(ndim == 1 and shape == (0, )):
# Passed a 0-by-0 matrix or empty vector; change shape to (0, 0)
shape = (0, 0)

elif ndim == 1:
Expand Down
30 changes: 30 additions & 0 deletions control/tests/interconnect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,36 @@ def test_linear_interconnect():
outlist=['plant.y'], outputs='y')
assert clsys.syslist[0].name == 'ctrl'


def test_interconnect_zero_input_one_output():
plant = ct.ss(
[[1, 1], [0, -2]],
[[0], [1]],
[[1, 0]],
[[0]],
inputs=['u'],
outputs=['y'],
name='plant',
dt=True,
)
controller = ct.ss(
[[2.25, 1], [-5, -0.5]],
[[-1.25], [4.5]],
[[-0.5, 1.5]],
[[0]],
inputs=['y'],
outputs=['u'],
name='controller',
dt=True,
)

sys = ct.interconnect([plant, controller], inplist=None, outlist=['y'])

assert sys.ninputs == 0
assert sys.noutputs == 1
assert sys.D.shape == (1, 0)


@pytest.mark.parametrize(
"connections, inplist, outlist, inputs, outputs", [
pytest.param(
Expand Down
Loading