cupy.unique_inverse#

cupy.unique_inverse(x)[source]#

Find the unique elements of x and indices to reconstruct x.

This function is Array API compatible alternative to:

>>> x = cupy.array([1, 1, 2])
>>> cupy.unique(x, return_inverse=True, equal_nan=False)
(array([1, 2]), array([0, 0, 1]))
Parameters:

x (ndarray) – Input array. It will be flattened if it is not already 1-D.

Returns:

out – The result containing:

  • values - The unique elements of an input array.

  • inverse_indices - The indices from the set of unique elements that reconstruct x.

Return type:

namedtuple

See also

unique

Find the unique elements of an array.

numpy.unique_inverse