MCPcopy Create free account
hub / github.com/numpy/numpy / test_sum

Method test_sum

numpy/matrixlib/tests/test_defmatrix.py:60–77  ·  view source on GitHub ↗

Test whether matrix.sum(axis=1) preserves orientation. Fails in NumPy <= 0.9.6.2127.

(self)

Source from the content-addressed store, hash-verified

58
59class 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]])

Callers

nothing calls this directly

Calls 4

matrixClass · 0.90
assert_array_equalFunction · 0.90
assert_equalFunction · 0.90
sumMethod · 0.45

Tested by

no test coverage detected