Is there a function similar to numpy unique with inverse?

See also:

And in particular this solution:

uniqueinds(x) = unique(i -> x[i], eachindex(x))

However, this isn’t quite the same thing: it’s equivalent to return_index=True in numpy.unique, not return_inverse=True.

2 Likes