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