Skip to content

Commit 186d6d8

Browse files
committed
YT algo cannot place multiple poles at the same location when rk(B)=1. Also, aadd tests for control dimension checks.
1 parent 99302cd commit 186d6d8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

control/tests/matlab_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,8 @@ def testModred(self):
400400
modred(self.siso_ss3, [1], 'matchdc')
401401
modred(self.siso_ss3, [1], 'truncate')
402402

403-
@unittest.skipIf(not slycot_check(), "slycot not installed")
404403
def testPlace(self):
405-
place(self.siso_ss1.A, self.siso_ss1.B, [-2, -2])
404+
place(self.siso_ss1.A, self.siso_ss1.B, [-2, -2.5])
406405

407406
@unittest.skipIf(not slycot_check(), "slycot not installed")
408407
def testLQR(self):

control/tests/statefbk_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99
from control.statefbk import ctrb, obsv, place, lqr, gram, acker
1010
from control.matlab import *
11-
from control.exception import slycot_check
11+
from control.exception import slycot_check, ControlDimension
1212

1313
class TestStatefbk(unittest.TestCase):
1414
"""Test state feedback functions"""
@@ -168,14 +168,18 @@ def testPlace(self):
168168
[1.136, 1.136],
169169
[0, 0,],
170170
[-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])
172172
K = place(A, B, P)
173173
P_placed = np.linalg.eigvals(A - B.dot(K))
174174
# No guarantee of the ordering, so sort them
175175
P.sort()
176176
P_placed.sort()
177177
np.testing.assert_array_almost_equal(P, P_placed)
178178

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+
179183
def check_LQR(self, K, S, poles, Q, R):
180184
S_expected = np.array(np.sqrt(Q * R))
181185
K_expected = S_expected / R

0 commit comments

Comments
 (0)