flopscope.

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

Areacore
Typecustom
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

Examples

>>> import flopscope.numpy as fnp
>>> flops.unique_values([1, 1, 2])
array([1, 2])