Skip to content

Commit

Permalink
Merge pull request #140 from rssalessio/master
Browse files Browse the repository at this point in the history
Fix minreal not returning a discrete TF
  • Loading branch information
murrayrm committed Jan 2, 2018
2 parents f890a88 + 585c028 commit 33bebc1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions control/tests/xferfcn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ def testMinreal(self):
hr = (s+1)/(s**2+s+1)
np.testing.assert_array_almost_equal(hm.num[0][0], hr.num[0][0])
np.testing.assert_array_almost_equal(hm.den[0][0], hr.den[0][0])
np.testing.assert_equal(hm.dt, hr.dt)

def testMinreal2(self):
"""This one gave a problem, due to poly([]) giving simply 1
Expand All @@ -474,12 +475,24 @@ def testMinreal2(self):
hr = 6205/(s**2+8*s+1241)
np.testing.assert_array_almost_equal(H2b.num[0][0], hr.num[0][0])
np.testing.assert_array_almost_equal(H2b.den[0][0], hr.den[0][0])
np.testing.assert_equal(H2b.dt, hr.dt)

def testMinreal3(self):
"""Regression test for minreal of tf([1,1],[1,1])"""
g = TransferFunction([1,1],[1,1]).minreal()
np.testing.assert_array_almost_equal(1.0, g.num[0][0])
np.testing.assert_array_almost_equal(1.0, g.den[0][0])
np.testing.assert_equal(None, g.dt)

def testMinreal4(self):
"""Check minreal on discrete TFs."""
T = 0.01
z = TransferFunction([1, 0], [1], T)
h = (z-1.00000000001)*(z+1.0000000001)/((z**2-1))
hm = h.minreal()
hr = TransferFunction([1], [1], T)
np.testing.assert_array_almost_equal(hm.num[0][0], hr.num[0][0])
np.testing.assert_equal(hr.dt, hm.dt)

@unittest.skipIf(not slycot_check(), "slycot not installed")
def testMIMO(self):
Expand Down
2 changes: 1 addition & 1 deletion control/xferfcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def minreal(self, tol=None):
den[i][j] = np.atleast_1d(real(poly(poles)))

# end result
return TransferFunction(num, den)
return TransferFunction(num, den, self.dt)

def returnScipySignalLTI(self):
"""Return a list of a list of scipy.signal.lti objects.
Expand Down

0 comments on commit 33bebc1

Please sign in to comment.