8000 - do not cancel pole/zero pairs before calculating pole() in xferfcn.py · python-control/python-control@7e594c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e594c4

Browse files
committed
- do not cancel pole/zero pairs before calculating pole() in xferfcn.py
- for the above reason, do conversion on minreal'd xferfcn in statesp.py - add a test for not canceling pole/zero pairs when calculating pole() - add import of matlab in discrete_test.py
1 parent 92a3354 commit 7e594c4

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

control/statesp.py

Lines changed: 1 addition & 1 deletion
< 8000 td data-grid-cell-id="diff-b5aac033a6dd07653e82d9f5a40afaa775010c2d2d5af8beeb159487b566df72-779-779-1" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">779
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ def _convertToStateSpace(sys, **kw):
776776
# Change the numerator and denominator arrays so that the transfer
777777
# function matrix has a common denominator.
778778
# matrices are also sized/padded to fit td04ad
779-
num, den, denorder = sys._common_den()
+
num, den, denorder = sys.minreal()._common_den()
780780

781781
# transfer function to state space conversion now should work!
782782
ssout = td04ad('C', sys.inputs, sys.outputs,

control/tests/discrete_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import unittest
77
import numpy as np
88
from control import *
9+
from control import matlab
910

1011
class TestDiscrete(unittest.TestCase):
1112
"""Tests for the DiscreteStateSpace class."""

control/tests/xferfcn_test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,14 @@ def testPoleMIMO(self):
427427

428428
np.testing.assert_array_almost_equal(p, [-2., -2., -7., -3., -2.])
429429

430-
# Tests for TransferFunction.feedback.
431-
430+
@unittest.skipIf(not slycot_check(), "slycot not installed")
431+
def testDoubleCancelingPoleSiso(self):
432+
433+
H = TransferFunction([1,1],[1,2,1])
434+
p = H.pole()
435+
np.testing.assert_array_almost_equal(p, [-1, -1])
436+
437+
# Tests for TransferFunction.feedback
432438
def testFeedbackSISO(self):
433439
"""Test for correct SISO transfer function feedback."""
434440

control/xferfcn.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,16 +752,17 @@ def _common_den(self, imag_tol=None):
752752
# pre-calculate the poles for all num, den
753753
# has zeros, poles, gain, list for pole indices not in den,
754754
# number of poles known at the time analyzed
755-
self2 = self.minreal()
755+
756+
# do not calculate minreal. Rory's hint .minreal()
756757
poleset = []
757758
for i in range(self.outputs):
758759
poleset.append([])
759760
for j in range(self.inputs):
760-
if abs(self2.num[i][j]).max() <= eps:
761+
if abs(self.num[i][j]).max() <= eps:
761762
poleset[-1].append( [array([], dtype=float),
762-
roots(self2.den[i][j]), 0.0, [], 0 ])
763+
roots(self.den[i][j]), 0.0, [], 0 ])
763764
else:
764-
z, p, k = tf2zpk(self2.num[i][j], self2.den[i][j])
765+
z, p, k = tf2zpk(self.num[i][j], self.den[i][j])
765766
poleset[-1].append([ z, p, k, [], 0])
766767

767768
# collect all individual poles

0 commit comments

Comments
 (0)
0