diff --git a/control/tests/xferfcn_test.py b/control/tests/xferfcn_test.py index fb8ae7c5b..c88dddcde 100644 --- a/control/tests/xferfcn_test.py +++ b/control/tests/xferfcn_test.py @@ -468,6 +468,12 @@ def testMinreal2(self): 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]) + 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]) + def testMIMO(self): """Test conversion of a single input, two-output state-space system against the same TF""" diff --git a/control/xferfcn.py b/control/xferfcn.py index 38e6b4198..7556d9049 100644 --- a/control/xferfcn.py +++ b/control/xferfcn.py @@ -678,12 +678,9 @@ def minreal(self, tol=None): # keep this zero newzeros.append(z) - # keep result - if len(newzeros): - num[i][j] = gain * real(poly(newzeros)) - else: - num[i][j] = array([gain]) - den[i][j] = real(poly(poles)) + # poly([]) returns a scalar, but we always want a 1d array + num[i][j] = np.atleast_1d(gain * real(poly(newzeros))) + den[i][j] = np.atleast_1d(real(poly(poles))) # end result return TransferFunction(num, den)