Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd5df69

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 parents5a0645b +7da17c8 commitfd5df69

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

‎control/tests/xferfcn_test.py

Lines changed: 6 additions & 0 deletions
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+
deftestMinreal3(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
deftestMIMO(self):
470476
"""Test conversion of a single input, two-output state-space
471477
system against the same TF"""

‎control/xferfcn.py

Lines changed: 3 additions & 6 deletions
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-
iflen(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
returnTransferFunction(num,den)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp