MCPcopy Index your code
hub / github.com/numpy/numpy / test_object_array_reduction

Method test_object_array_reduction

numpy/_core/tests/test_ufunc.py:1579–1596  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1577 assert_equal(np.equal(arr1d, arr1d, dtype=object), np.array(['==']))
1578
1579 def test_object_array_reduction(self):
1580 # Reductions on object arrays
1581 a = np.array(['a', 'b', 'c'], dtype=object)
1582 assert_equal(np.sum(a), 'abc')
1583 assert_equal(np.max(a), 'c')
1584 assert_equal(np.min(a), 'a')
1585 a = np.array([True, False, True], dtype=object)
1586 assert_equal(np.sum(a), 2)
1587 assert_equal(np.prod(a), 0)
1588 assert_equal(np.any(a), True)
1589 assert_equal(np.all(a), False)
1590 assert_equal(np.max(a), True)
1591 assert_equal(np.min(a), False)
1592 assert_equal(np.array([[1]], dtype=object).sum(), 1)
1593 assert_equal(np.array([[[1, 2]]], dtype=object).sum((0, 1)), [1, 2])
1594 assert_equal(np.array([1], dtype=object).sum(initial=1), 2)
1595 assert_equal(np.array([[1], [2, 3]], dtype=object)
1596 .sum(initial=[0], where=[False, True]), [0, 2, 3])
1597
1598 def test_object_array_accumulate_inplace(self):
1599 # Checks that in-place accumulates work, see also gh-7402

Callers

nothing calls this directly

Calls 7

assert_equalFunction · 0.90
sumMethod · 0.45
maxMethod · 0.45
minMethod · 0.45
prodMethod · 0.45
anyMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected