Mercurial > hg > tvii
diff tests/test_transpose.py @ 69:0bb36ae047c3
test matrix transposition
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 17 Dec 2017 13:16:16 -0800 |
parents | |
children | 9d55e0299c3f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_transpose.py Sun Dec 17 13:16:16 2017 -0800 @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +""" +test matrix data transposition +""" + +import unittest +from tvii.transpose import transpose +from tvii.transpose import NotAMatrix + + +class TestTranspose(unittest.TestCase): + + def test_transpose(self): + data = [[1.0, 0.0], + [2.0, -1.0], + [3.0, -2.0], + [4.0, -3.0]] + transposed = [[1.0, 2., 3., 4.], + [0., -1., -2., -3]] + assert (transpose(data) == transposed) + + def test_not_a_matrix(self): + + not_a_matrix = [[1,2,3], + [4,5,6], + [7, 8, 9, 10] # oops + ] + e = None + try: + transpose(not_a_matrix) + except NotAMatrix as e: + pass + assert e is not None + assert isinstance(e, NotAMatrix) + +if __name__ == '__main__': + unittest.main()