-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrlocus_test.py
More file actions
38 lines (30 loc) · 1.12 KB
/
Copy pathrlocus_test.py
File metadata and controls
38 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
#
# rlocus_test.py - unit test for root locus diagrams
# RMM, 1 Jul 2011
import unittest
import numpy as np
from control.rlocus import root_locus
from control.xferfcn import TransferFunction
from control.statesp import StateSpace
from control.bdalg import feedback
class TestRootLocus(unittest.TestCase):
"""These are tests for the feedback function in rlocus.py."""
def setUp(self):
"""This contains some random LTI systems and scalars for testing."""
# Two random SISO systems.
self.sys1 = TransferFunction([1, 2], [1, 2, 3])
self.sys2 = StateSpace([[1., 4.], [3., 2.]], [[1.], [-4.]],
[[1., 0.]], [[0.]])
def testRootLocus(self):
"""Basic root locus plot"""
klist = [-1, 0, 1]
rlist = root_locus(self.sys1, [-1, 0, 1], Plot=False)
for k in klist:
np.testing.assert_array_almost_equal(
np.sort(rlist[k]),
np.sort(feedback(self.sys1, klist[k]).pole()))
def suite():
return unittest.TestLoader().loadTestsFromTestCase(TestRootLocus)
if __name__ == "__main__":
unittest.main()