Skip to content

Commit ed4590c

Browse files
author
Daniel Bankmann
committed
moved tests to appropriate position
1 parent 3ece9aa commit ed4590c

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

control/tests/statefbk_test.py

+32
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from control.statefbk import ctrb, obsv, place, place_varga, lqr, gram, acker
1010
from control.matlab import *
1111
from control.exception import slycot_check, ControlDimension
12+
from control.mateqn import care, dare
1213

1314
class TestStatefbk(unittest.TestCase):
1415
"""Test state feedback functions"""
@@ -298,6 +299,37 @@ def test_LQR_3args(self):
298299
K, S, poles = lqr(sys, Q, R)
299300
self.check_LQR(K, S, poles, Q, R)
300301

302+
@unittest.skipIf(not slycot_check(), "slycot not installed")
303+
def test_care(self):
304+
#unit test for stabilizing and anti-stabilizing feedbacks
305+
#continuous-time
306+
307+
A = np.diag([1,-1])
308+
B = np.identity(2)
309+
Q = np.identity(2)
310+
R = np.identity(2)
311+
S = 0 * B
312+
E = np.identity(2)
313+
X, L , G = care(A, B, Q, R, S, E, stabilizing=True)
314+
assert np.all(np.real(L) < 0)
315+
X, L , G = care(A, B, Q, R, S, E, stabilizing=False)
316+
assert np.all(np.real(L) > 0)
317+
318+
@unittest.skipIf(not slycot_check(), "slycot not installed")
319+
def test_dare(self):
320+
#discrete-time
321+
A = np.diag([0.5,2])
322+
B = np.identity(2)
323+
Q = np.identity(2)
324+
R = np.identity(2)
325+
S = 0 * B
326+
E = np.identity(2)
327+
X, L , G = dare(A, B, Q, R, S, E, stabilizing=True)
328+
assert np.all(np.abs(L) < 1)
329+
X, L , G = dare(A, B, Q, R, S, E, stabilizing=False)
330+
assert np.all(np.abs(L) > 1)
331+
332+
301333
def test_suite():
302334
return unittest.TestLoader().loadTestsFromTestCase(TestStatefbk)
303335

examples/test-riccati.py

-30
This file was deleted.

0 commit comments

Comments
 (0)