Skip to content

Commit 508bc8b

Browse files
committed
Add MIMO-SISO add for TF
1 parent bbf605d commit 508bc8b

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

control/tests/xferfcn_test.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,28 @@ def test_constructor_double_dt(self):
113113

114114
def test_add_inconsistent_dimension(self):
115115
"""Add two transfer function matrices of different sizes."""
116-
sys1 = TransferFunction([[[1., 2.]]], [[[4., 5.]]])
117-
sys2 = TransferFunction([[[4., 3.]], [[1., 2.]]],
118-
[[[1., 6.]], [[2., 4.]]])
116+
sys1 = TransferFunction(
117+
[
118+
[[1., 2.]],
119+
[[2., -2.]],
120+
[[2., 1.]],
121+
],
122+
[
123+
[[4., 5.]],
124+
[[5., 2.]],
125+
[[3., 2.]],
126+
],
127+
)
128+
sys2 = TransferFunction(
129+
[
130+
[[4., 3.]],
131+
[[1., 2.]],
132+
],
133+
[
134+
[[1., 6.]],
135+
[[2., 4.]],
136+
]
137+
)
119138
with pytest.raises(ValueError):
120139
sys1.__add__(sys2)
121140
with pytest.raises(ValueError):

control/xferfcn.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,12 @@ def __add__(self, other):
594594
if not isinstance(other, TransferFunction):
595595
return NotImplemented
596596

597+
# Promote SISO object to compatible dimension
598+
if self.issiso() and not other.issiso():
599+
self = np.ones((other.noutputs, other.ninputs)) * self
600+
elif not self.issiso() and other.issiso():
601+
other = np.ones((self.noutputs, self.ninputs)) * other
602+
597603
# Check that the input-output sizes are consistent.
598604
if self.ninputs != other.ninputs:
599605
raise ValueError(

0 commit comments

Comments
 (0)