MCPcopy
hub / github.com/numpy/numpy / test_addsumprod

Method test_addsumprod

numpy/ma/tests/test_core.py:1504–1526  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1502 minmax_with_mask(x, m)
1503
1504 def test_addsumprod(self):
1505 # Tests add, sum, product.
1506 x, y, _, _, _, xm, ym, _, _, _ = self._create_data()
1507 assert_equal(np.add.reduce(x), add.reduce(x))
1508 assert_equal(np.add.accumulate(x), add.accumulate(x))
1509 assert_equal(4, sum(array(4), axis=0))
1510 assert_equal(4, sum(array(4), axis=0))
1511 assert_equal(np.sum(x, axis=0), sum(x, axis=0))
1512 assert_equal(np.sum(filled(xm, 0), axis=0), sum(xm, axis=0))
1513 assert_equal(np.sum(x, 0), sum(x, 0))
1514 assert_equal(np.prod(x, axis=0), product(x, axis=0))
1515 assert_equal(np.prod(x, 0), product(x, 0))
1516 assert_equal(np.prod(filled(xm, 1), axis=0), product(xm, axis=0))
1517 s = (3, 4)
1518 x = x.reshape(s)
1519 y = y.reshape(s)
1520 xm = xm.reshape(s)
1521 ym = ym.reshape(s)
1522 if len(s) > 1:
1523 assert_equal(np.concatenate((x, y), 1), concatenate((xm, ym), 1))
1524 assert_equal(np.add.reduce(x, 1), add.reduce(x, 1))
1525 assert_equal(np.sum(x, 1), sum(x, 1))
1526 assert_equal(np.prod(x, 1), product(x, 1))
1527
1528 def test_binops_d2D(self):
1529 # Test binary operations on 2D data

Callers

nothing calls this directly

Calls 11

_create_dataMethod · 0.95
assert_equalFunction · 0.90
sumFunction · 0.90
arrayFunction · 0.90
filledFunction · 0.90
concatenateFunction · 0.90
accumulateMethod · 0.80
reshapeMethod · 0.80
reduceMethod · 0.45
sumMethod · 0.45
prodMethod · 0.45

Tested by

no test coverage detected