Skip to content

Commit 9316665

Browse files
author
Kevin Chen
committed
reorganized testing into src/test.py
I changed a bunch of things, basically enabling one to do import control control.tests() I'm a little unsure on the whole setup of the directories, so if it doesn't work then I'll fix it. -brandt bbelson@rainier.princeton.edu
1 parent 01b42ce commit 9316665

8 files changed

Lines changed: 40 additions & 2 deletions

File tree

src/TestBDAlg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ def testTFTF(self):
159159
[[[1., 4., 11., 16., 13.]]])
160160
np.testing.assert_array_almost_equal(ans2.num, [[[1., 4., 7., 6.]]])
161161
np.testing.assert_array_almost_equal(ans2.den, [[[1., 4., 9., 8., 5.]]])
162+
def suite():
163+
return unittest.TestLoader().loadTestsFromTestCase(TestFeedback)
162164

163165
if __name__ == "__main__":
164166
unittest.main()

src/TestConvert.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,8 @@ def testConvert(self):
6060
sys4 = matlab.tf(sys3)
6161
self.printSys(sys4, 4)
6262

63+
def suite():
64+
return unittest.TestLoader().loadTestsFromTestCase(TestConvert)
65+
6366
if __name__ == "__main__":
6467
unittest.main()

src/TestFreqRsp.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env python
22

3+
### MUST BE CONVERTED TO A UNIT TEST!!!
4+
5+
36
# Script to test frequency response and frequency response plots like bode, nyquist and gang of 4.
47
# Especially need to ensure that nothing SISO is broken and that MIMO at least handles exceptions and has some default to SISO in place.
58

9+
10+
import unittest
611
from statesp import StateSpace
712
from matlab import ss, tf, bode
813
import numpy as np
@@ -49,4 +54,7 @@
4954
#plt.semilogx(omega,20*np.log10(np.squeeze(frq[0])))
5055

5156
#plt.figure(4)
52-
#bode(sysMIMO,omega)
57+
#bode(sysMIMO,omega)
58+
59+
def suite():
60+
return unittest.TestLoader().loadTestsFromTestCase(TestConvert)

src/TestMatlab.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@ def testImpulse(self):
4040
# np.testing.assert_array_almost_equal(yout, youttrue,decimal=4)
4141

4242

43+
def suite():
44+
return unittest.TestLoader().loadTestsFromTestCase(TestMatlab)
45+
4346
if __name__ == '__main__':
4447
unittest.main()

src/TestSlycot.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#!/usr/bin/env python
2+
3+
#### THIS MUST BE MADE INTO A UNITTEST TO BE PART OF THE TESTING FUNCTIONS!!!!
4+
5+
16
import numpy as np
27
from slycot import tb04ad, td04ad
38
import matlab
@@ -28,3 +33,10 @@
2833
print "sys4"
2934
print sys4
3035

36+
#These are here for once the above is made into a unittest.
37+
def suite():
38+
return unittest.TestLoader().loadTestsFromTestCase(TestSlycot)
39+
40+
if __name__=='__main__':
41+
unittest.main()
42+

src/TestStateSp.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ def testPole(self):
199199
p = sys.pole()
200200
for z in p:
201201
self.assertTrue(abs(z) < 1)
202-
202+
203+
204+
def suite():
205+
return unittest.TestLoader().loadTestsFromTestCase(TestStateSpace)
206+
207+
203208
if __name__ == "__main__":
204209
unittest.main()

src/TestXferFcn.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,5 +430,8 @@ def testConvertToTransferFunction(self):
430430
np.testing.assert_array_almost_equal(tfsys.num[i][j], num[i][j])
431431
np.testing.assert_array_almost_equal(tfsys.den[i][j], den[i][j])
432432

433+
def suite():
434+
return unittest.TestLoader().loadTestsFromTestCase(TestXferFcn)
435+
433436
if __name__ == "__main__":
434437
unittest.main()

src/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@
6262
from bdalg import *
6363
from statefbk import *
6464
from delay import *
65+
66+
from test import *

0 commit comments

Comments
 (0)