cupy.put_along_axis(arr, indices, values, axis)[source]#

Put values into the destination array by matching 1d index and data slices.

This iterates over matching 1d slices oriented along the specified axis in the index and data arrays, and uses the former to place values into the latter. These slices can be different lengths.

Functions returning an index along an axis, like argsort and argpartition, produce suitable indices for this function.

  • arr – cupy.ndarray (Ni…, M, Nk…) Destination array.

  • indices – cupy.ndarray (Ni…, J, Nk…) Indices to change along each 1d slice of arr. This must match the dimension of arr, but dimensions in Ni and Nj may be 1 to broadcast against arr.

  • values – array_like (Ni…, J, Nk…) values to insert at those indices. Its shape and dimension are broadcast to match that of indices.

  • axis – int The axis to take 1d slices along. If axis is None, the destination array is treated as if a flattened 1d view had been created of it.