69
|
1 #!/usr/bin/env python
|
|
2
|
|
3 """
|
|
4 test matrix data transposition
|
|
5 """
|
|
6
|
|
7 import unittest
|
|
8 from tvii.transpose import transpose
|
|
9 from tvii.transpose import NotAMatrix
|
|
10
|
|
11
|
|
12 class TestTranspose(unittest.TestCase):
|
|
13
|
|
14 def test_transpose(self):
|
|
15 data = [[1.0, 0.0],
|
|
16 [2.0, -1.0],
|
|
17 [3.0, -2.0],
|
|
18 [4.0, -3.0]]
|
|
19 transposed = [[1.0, 2., 3., 4.],
|
|
20 [0., -1., -2., -3]]
|
|
21 assert (transpose(data) == transposed)
|
|
22
|
|
23 def test_not_a_matrix(self):
|
|
24
|
|
25 not_a_matrix = [[1,2,3],
|
|
26 [4,5,6],
|
|
27 [7, 8, 9, 10] # oops
|
|
28 ]
|
|
29 e = None
|
|
30 try:
|
|
31 transpose(not_a_matrix)
|
71
|
32 except NotAMatrix as _e:
|
|
33 e = _e
|
69
|
34 assert e is not None
|
|
35 assert isinstance(e, NotAMatrix)
|
|
36
|
|
37 if __name__ == '__main__':
|
|
38 unittest.main()
|