MCPcopy
hub / github.com/numpy/numpy / test_sum

Method test_sum

numpy/matrixlib/tests/test_defmatrix.py:64–81  ·  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

62
63class 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]])

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