Skip to content

Commit fd5df69

Browse files
authored
Merge pull request #104 from roryyorke/rory-tf-minreal-bug
Bugfix: xferfcn.TransferFunction can now be minreal'ed to a static gain.
2 parents 5a0645b + 7da17c8 commit fd5df69

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

control/tests/xferfcn_test.py

+6
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ def testMinreal2(self):
466466
np.testing.assert_array_almost_equal(H2b.num[0][0], hr.num[0][0])
467467
np.testing.assert_array_almost_equal(H2b.den[0][0], hr.den[0][0])
468468

469+
def testMinreal3(self):
470+
"""Regression test for minreal of tf([1,1],[1,1])"""
471+
g = TransferFunction([1,1],[1,1]).minreal()
472+
np.testing.assert_array_almost_equal(1.0, g.num[0][0])
473+
np.testing.assert_array_almost_equal(1.0, g.den[0][0])
474+
469475
def testMIMO(self):
470476
"""Test conversion of a single input, two-output state-space
471477
system against the same TF"""

control/xferfcn.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -678,12 +678,9 @@ def minreal(self, tol=None):
678678
# keep this zero
679679
newzeros.append(z)
680680

681-
# keep result
682-
if len(newzeros):
683-
num[i][j] = gain * real(poly(newzeros))
684-
else:
685-
num[i][j] = array([gain])
686-
den[i][j] = real(poly(poles))
681+
# poly([]) returns a scalar, but we always want a 1d array
682+
num[i][j] = np.atleast_1d(gain * real(poly(newzeros)))
683+
den[i][j] = np.atleast_1d(real(poly(poles)))
687684

688685
# end result
689686
return TransferFunction(num, den)

0 commit comments

Comments
 (0)