cunumeric.compress#

cunumeric.compress(condition: ndarray, a: ndarray, axis: int | None = None, out: ndarray | None = None) ndarray#

Return selected slices of an array along given axis.

When working along a given axis, a slice along that axis is returned in output for each index where condition evaluates to True. When working on a 1-D array, compress is equivalent to numpy.extract.

Parameters:
  • condition – Array that selects which entries to return. If len(c) is less than the size of a along the given axis, then output is truncated to the length of the condition array.

  • bools (1-D array of) – Array that selects which entries to return. If len(c) is less than the size of a along the given axis, then output is truncated to the length of the condition array.

  • a (array_like) – Array from which to extract a part.

  • axis (int, optional) – Axis along which to take slices. If None (default), work on the flattened array.

  • out (ndarray, optional) – Output array. Its type is preserved and it must be of the right shape to hold the output.

Returns:

compressed_array – A copy of a without the slices along axis for which condition is false.

Return type:

ndarray

:raises ValueError : dimension mismatch: If condition is not 1D array :raises ValueError : shape mismatch: If condition contains entries that are out of bounds of array :raises ValueError : shape mismatch: If output array has a wrong shape

Availability:

Multiple GPUs, Multiple CPUs