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

Method test_object_array_accumulate_inplace

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

Source from the content-addressed store, hash-verified

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
1408 arr = np.ones(4, dtype=object)
1409 arr[:] = [[1] for i in range(4)]
1410 # Twice reproduced also for tuples:
1411 np.add.accumulate(arr, out=arr)
1412 np.add.accumulate(arr, out=arr)
1413 assert_array_equal(arr,
1414 np.array([[1]*i for i in [1, 3, 6, 10]], dtype=object),
1415 )
1416
1417 # And the same if the axis argument is used
1418 arr = np.ones((2, 4), dtype=object)
1419 arr[0, :] = [[2] for i in range(4)]
1420 np.add.accumulate(arr, out=arr, axis=-1)
1421 np.add.accumulate(arr, out=arr, axis=-1)
1422 assert_array_equal(arr[0, :],
1423 np.array([[2]*i for i in [1, 3, 6, 10]], dtype=object),
1424 )
1425
1426 def test_object_array_accumulate_failure(self):
1427 # Typical accumulation on object works as expected:

Callers

nothing calls this directly

Calls 2

assert_array_equalFunction · 0.90
accumulateMethod · 0.80

Tested by

no test coverage detected