Skip to content

Commit 1ea3a38

Browse files
author
Kevin Chen
committed
Added rss unit tests.
Kevin K. Chen <kkchen@princeton.edu>
1 parent d1b6b80 commit 1ea3a38

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

src/TestStateSp.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
3+
import numpy as np
4+
import statesp as ss
5+
import unittest
6+
7+
class TestRss(unittest.TestCase):
8+
"""These are tests for the proper functionality of statesp.rss."""
9+
10+
def setUp(self):
11+
# Number of times to run each of the randomized tests.
12+
self.numTests = 100
13+
14+
def testShape(self):
15+
"""Test that rss outputs have the right state, input, and output
16+
size."""
17+
18+
for states in range(1, 10):
19+
for inputs in range(1, 5):
20+
for outputs in range(1, 5):
21+
sys = ss.rss(states, inputs, outputs)
22+
self.assertEqual(sys.states, states)
23+
self.assertEqual(sys.inputs, inputs)
24+
self.assertEqual(sys.outputs, outputs)
25+
26+
def testPole(self):
27+
"""Test that the poles of rss outputs have a negative real part."""
28+
29+
for states in range(1, 10):
30+
for inputs in range(1, 5):
31+
for outputs in range(1, 5):
32+
sys = ss.rss(states, inputs, outputs)
33+
p = sys.poles()
34+
for z in p:
35+
self.assertTrue(z.real < 0)
36+
37+
if __name__ == "__main__":
38+
unittest.main()

0 commit comments

Comments
 (0)