Test whether matrix.sum(axis=1) preserves orientation. Fails in NumPy <= 0.9.6.2127.
(self)
| 62 | |
| 63 | class TestProperties: |
| 64 | def test_sum(self): |
| 65 | """Test whether matrix.sum(axis=1) preserves orientation. |
| 66 | Fails in NumPy <= 0.9.6.2127. |
| 67 | """ |
| 68 | M = matrix([[1, 2, 0, 0], |
| 69 | [3, 4, 0, 0], |
| 70 | [1, 2, 1, 2], |
| 71 | [3, 4, 3, 4]]) |
| 72 | sum0 = matrix([8, 12, 4, 6]) |
| 73 | sum1 = matrix([3, 7, 6, 14]).T |
| 74 | sumall = 30 |
| 75 | assert_array_equal(sum0, M.sum(axis=0)) |
| 76 | assert_array_equal(sum1, M.sum(axis=1)) |
| 77 | assert_equal(sumall, M.sum()) |
| 78 | |
| 79 | assert_array_equal(sum0, np.sum(M, axis=0)) |
| 80 | assert_array_equal(sum1, np.sum(M, axis=1)) |
| 81 | assert_equal(sumall, np.sum(M)) |
| 82 | |
| 83 | def test_prod(self): |
| 84 | x = matrix([[1, 2, 3], [4, 5, 6]]) |
nothing calls this directly
no test coverage detected