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

Method test_object_array_reduction

numpy/core/tests/test_ufunc.py:1387–1404  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1385 assert_equal(np.equal(arr1d, arr1d, dtype=object), np.array(['==']))
1386
1387 def test_object_array_reduction(self):
1388 # Reductions on object arrays
1389 a = np.array(['a', 'b', 'c'], dtype=object)
1390 assert_equal(np.sum(a), 'abc')
1391 assert_equal(np.max(a), 'c')
1392 assert_equal(np.min(a), 'a')
1393 a = np.array([True, False, True], dtype=object)
1394 assert_equal(np.sum(a), 2)
1395 assert_equal(np.prod(a), 0)
1396 assert_equal(np.any(a), True)
1397 assert_equal(np.all(a), False)
1398 assert_equal(np.max(a), True)
1399 assert_equal(np.min(a), False)
1400 assert_equal(np.array([[1]], dtype=object).sum(), 1)
1401 assert_equal(np.array([[[1, 2]]], dtype=object).sum((0, 1)), [1, 2])
1402 assert_equal(np.array([1], dtype=object).sum(initial=1), 2)
1403 assert_equal(np.array([[1], [2, 3]], dtype=object)
1404 .sum(initial=[0], where=[False, True]), [0, 2, 3])
1405
1406 def test_object_array_accumulate_inplace(self):
1407 # 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