|
8 | 8 | import numpy as np |
9 | 9 | from control.statefbk import ctrb, obsv, place, lqr, gram, acker |
10 | 10 | from control.matlab import * |
11 | | -from control.exception import slycot_check |
| 11 | +from control.exception import slycot_check, ControlDimension |
12 | 12 |
|
13 | 13 | class TestStatefbk(unittest.TestCase): |
14 | 14 | """Test state feedback functions""" |
@@ -168,14 +168,18 @@ def testPlace(self): |
168 | 168 | [1.136, 1.136], |
169 | 169 | [0, 0,], |
170 | 170 | [-3.146, 0]]) |
171 | | - P = np.array([-0.2, -0.5, -5.0566, -8.6659]) |
| 171 | + P = np.array([-0.5+1j, -0.5-1j, -5.0566, -8.6659]) |
172 | 172 | K = place(A, B, P) |
173 | 173 | P_placed = np.linalg.eigvals(A - B.dot(K)) |
174 | 174 | # No guarantee of the ordering, so sort them |
175 | 175 | P.sort() |
176 | 176 | P_placed.sort() |
177 | 177 | np.testing.assert_array_almost_equal(P, P_placed) |
178 | 178 |
|
| 179 | + # Test that the dimension checks work. |
| 180 | + np.testing.assert_raises(ControlDimension, place, A[1:, :], B, P) |
| 181 | + np.testing.assert_raises(ControlDimension, place, A, B[1:, :], P) |
| 182 | + |
179 | 183 | def check_LQR(self, K, S, poles, Q, R): |
180 | 184 | S_expected = np.array(np.sqrt(Q * R)) |
181 | 185 | K_expected = S_expected / R |
|
0 commit comments