Skip to content

Commit b246884

Browse files
authored
Merge pull request #273 from don4get/fix/ss2tf-python27
Fix ss2tf in case state space matrices are made of int values.
2 parents c30746a + a4e4786 commit b246884

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

control/statesp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _matrix(a):
8484
module.
8585
"""
8686
from numpy import matrix
87-
am = matrix(a)
87+
am = matrix(a, dtype=float)
8888
if (1, 0) == am.shape:
8989
am.shape = (0, 0)
9090
return am

control/tests/xferfcn_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,16 @@ def test_dcgain_discr(self):
600600
sys = TransferFunction([1,-1], [1], True)
601601
np.testing.assert_equal(sys.dcgain(), 0)
602602

603+
def test_ss2tf(self):
604+
A = np.array([[-4, -1], [-1, -4]])
605+
B = np.array([[1], [3]])
606+
C = np.array([[3, 1]])
607+
D = 0
608+
sys = ss2tf(A, B, C, D)
609+
true_sys = TransferFunction([6., 14.], [1., 8., 15.])
610+
np.testing.assert_almost_equal(sys.num, true_sys.num)
611+
np.testing.assert_almost_equal(sys.den, true_sys.den)
612+
603613

604614
def suite():
605615
return unittest.TestLoader().loadTestsFromTestCase(TestXferFcn)

0 commit comments

Comments
 (0)