cupy.compress#

cupy.compress(condition, a, axis=None, out=None)[source]#

Returns selected slices of an array along given axis.

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

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

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

  • out (cupy.ndarray) – Output array. If provided, it should be of appropriate shape and dtype.

Returns

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

Return type

cupy.ndarray

Warning

This function may synchronize the device.

See also

numpy.compress()