Source code for cupy.indexing.indexing

[docs]def take(a, indices, axis=None, out=None): """Takes elements of an array at specified indices along an axis. This is an implementation of "fancy indexing" at single axis. This function does not support ``mode`` option. Args: a (cupy.ndarray): Array to extract elements. indices (int or array-like): Indices of elements that this function takes. axis (int): The axis along which to select indices. The flattened input is used by default. out (cupy.ndarray): Output array. If provided, it should be of appropriate shape and dtype. Returns: cupy.ndarray: The result of fancy indexing. .. seealso:: :func:`numpy.take` """ # TODO(okuta): check type return a.take(indices, axis, out)
def choose(a, choices, out=None, mode='raise'): return a.choose(choices, out, mode) # TODO(okuta): Implement compress
[docs]def diagonal(a, offset=0, axis1=0, axis2=1): """Returns specified diagonals. This function extracts the diagonals along two specified axes. The other axes are not changed. This function returns a writable view of this array as NumPy 1.10 will do. Args: a (cupy.ndarray): Array from which the diagonals are taken. offset (int): Index of the diagonals. Zero indicates the main diagonals, a positive value upper diagonals, and a negative value lower diagonals. axis1 (int): The first axis to take diagonals from. axis2 (int): The second axis to take diagonals from. Returns: cupy.ndarray: A view of the diagonals of ``a``. .. seealso:: :func:`numpy.diagonal` """ # TODO(okuta): check type return a.diagonal(offset, axis1, axis2)
# TODO(okuta): Implement select