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