|
5 | 5 |
|
6 | 6 | import unittest
|
7 | 7 | import numpy as np
|
8 |
| -from control.statesp import StateSpace, _convertToStateSpace |
9 |
| -from control.xferfcn import TransferFunction, _convertToTransferFunction |
| 8 | +from control.statesp import StateSpace, _convertToStateSpace, rss |
| 9 | +from control.xferfcn import TransferFunction, _convertToTransferFunction, ss2tf |
10 | 10 | from control.lti import evalfr
|
11 | 11 | from control.exception import slycot_check
|
12 | 12 | # from control.lti import isdtime
|
@@ -536,6 +536,25 @@ def testMIMO(self):
|
536 | 536 | np.testing.assert_array_almost_equal(H.num[1][0], H2.num[1][0])
|
537 | 537 | np.testing.assert_array_almost_equal(H.den[1][0], H2.den[1][0])
|
538 | 538 |
|
| 539 | + def testIndexing(self): |
| 540 | + tm = ss2tf(rss(5, 3, 3)) |
| 541 | + |
| 542 | + # scalar indexing |
| 543 | + sys01 = tm[0, 1] |
| 544 | + np.testing.assert_array_almost_equal(sys01.num[0][0], tm.num[0][1]) |
| 545 | + np.testing.assert_array_almost_equal(sys01.den[0][0], tm.den[0][1]) |
| 546 | + |
| 547 | + # slice indexing |
| 548 | + sys = tm[:2, 1:3] |
| 549 | + np.testing.assert_array_almost_equal(sys.num[0][0], tm.num[0][1]) |
| 550 | + np.testing.assert_array_almost_equal(sys.den[0][0], tm.den[0][1]) |
| 551 | + np.testing.assert_array_almost_equal(sys.num[0][1], tm.num[0][2]) |
| 552 | + np.testing.assert_array_almost_equal(sys.den[0][1], tm.den[0][2]) |
| 553 | + np.testing.assert_array_almost_equal(sys.num[1][0], tm.num[1][1]) |
| 554 | + np.testing.assert_array_almost_equal(sys.den[1][0], tm.den[1][1]) |
| 555 | + np.testing.assert_array_almost_equal(sys.num[1][1], tm.num[1][2]) |
| 556 | + np.testing.assert_array_almost_equal(sys.den[1][1], tm.den[1][2]) |
| 557 | + |
539 | 558 | def testMatrixMult(self):
|
540 | 559 | """MIMO transfer functions should be multiplyable by constant
|
541 | 560 | matrices"""
|
|
0 commit comments