flopscope.numpy.unique_values
fnp.unique_values(x: 'ArrayLike', /) -> 'FlopscopeArray'[flopscope source][numpy source]
Returns the unique elements of an input array `x`.
Adapted from NumPy docs np.unique_values
Cost
per-operation
Flopscope Context
Sort-based unique; cost = n*ceil(log2(n)).
Returns the unique elements of an input array x.
This function is an Array API compatible alternative to:
flops.unique(x, equal_nan=False)Parameters
- x:array_like
Input array. It will be flattened if it is not already 1-D.
Returns
- out:ndarray
The unique elements of an input array.
See also
- we.flops.unique Find the unique elements of an array.
Examples
>>> import flopscope.numpy as fnp
>>> flops.unique_values([1, 1, 2])
array([1, 2])