cunumeric.take#

cunumeric.take(a: ndarray, indices: ndarray, axis: int | None = None, out: ndarray | None = None, mode: BoundsMode = 'raise') ndarray#

Take elements from an array along an axis. When axis is not None, this function does the same thing as “fancy” indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis. A call such as np.take(arr, indices, axis=3) is equivalent to arr[:,:,:,indices,…].

Parameters:
  • a (array_like (Ni…, M, Nk…)) – The source array.

  • indices (array_like (Nj…)) – The indices of the values to extract. Also allow scalars for indices.

  • axis (int, optional) – The axis over which to select values. By default, the flattened input array is used.

  • out (ndarray, optional (Ni…, Nj…, Nk…)) – If provided, the result will be placed in this array. It should be of the appropriate shape and dtype.

  • mode ({'raise', 'wrap', 'clip'}, optional) – Specifies how out-of-bounds indices will behave. ‘raise’ - raise an error (default) ‘wrap’ - wrap around ‘clip’ - clip to the range ‘clip’ mode means that all indices that are too large are replaced by the index that addresses the last element along that axis. Note that this disables indexing with negative numbers.

Returns:

out – The returned array has the same type as a.

Return type:

ndarray (Ni…, Nj…, Nk…)

See also

numpy.take

Availability:

Multiple GPUs, Multiple CPUs