| 11 | |
| 12 | class TestCtor: |
| 13 | def test_basic(self): |
| 14 | A = np.array([[1, 2], [3, 4]]) |
| 15 | mA = matrix(A) |
| 16 | assert_(np.all(mA.A == A)) |
| 17 | |
| 18 | B = bmat("A,A;A,A") |
| 19 | C = bmat([[A, A], [A, A]]) |
| 20 | D = np.array([[1, 2, 1, 2], |
| 21 | [3, 4, 3, 4], |
| 22 | [1, 2, 1, 2], |
| 23 | [3, 4, 3, 4]]) |
| 24 | assert_(np.all(B.A == D)) |
| 25 | assert_(np.all(C.A == D)) |
| 26 | |
| 27 | E = np.array([[5, 6], [7, 8]]) |
| 28 | AEresult = matrix([[1, 2, 5, 6], [3, 4, 7, 8]]) |
| 29 | assert_(np.all(bmat([A, E]) == AEresult)) |
| 30 | |
| 31 | vec = np.arange(5) |
| 32 | mvec = matrix(vec) |
| 33 | assert_(mvec.shape == (1, 5)) |
| 34 | |
| 35 | def test_exceptions(self): |
| 36 | # Check for ValueError when called with invalid string data. |