Skip to content

Commit 585c028

Browse files
committed
change if to None. add tests
1 parent d8d6b02 commit 585c028

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

control/tests/xferfcn_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ def testMinreal(self):
461461
hr = (s+1)/(s**2+s+1)
462462
np.testing.assert_array_almost_equal(hm.num[0][0], hr.num[0][0])
463463
np.testing.assert_array_almost_equal(hm.den[0][0], hr.den[0][0])
464+
np.testing.assert_equal(hm.dt, hr.dt)
464465

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

478480
def testMinreal3(self):
479481
"""Regression test for minreal of tf([1,1],[1,1])"""
480482
g = TransferFunction([1,1],[1,1]).minreal()
481483
np.testing.assert_array_almost_equal(1.0, g.num[0][0])
482484
np.testing.assert_array_almost_equal(1.0, g.den[0][0])
485+
np.testing.assert_equal(None, g.dt)
486+
487+
def testMinreal4(self):
488+
"""Check minreal on discrete TFs."""
489+
T = 0.01
490+
z = TransferFunction([1, 0], [1], T)
491+
h = (z-1.00000000001)*(z+1.0000000001)/((z**2-1))
492+
hm = h.minreal()
493+
hr = TransferFunction([1], [1], T)
494+
np.testing.assert_array_almost_equal(hm.num[0][0], hr.num[0][0])
495+
np.testing.assert_equal(hr.dt, hm.dt)
483496

484497
@unittest.skipIf(not slycot_check(), "slycot not installed")
485498
def testMIMO(self):

control/xferfcn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ def minreal(self, tol=None):
685685
den[i][j] = np.atleast_1d(real(poly(poles)))
686686

687687
# end result
688-
return TransferFunction(num, den, None if self.dt == None else self.dt)
688+
return TransferFunction(num, den, self.dt)
689689

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

0 commit comments

Comments
 (0)