I’m not sure how that works in numpy in the first place - is unique_vals not a proper numpy array but rather some special construct? unique in julia doesn’t give you a slice or view into the existing array, it creates a new array with the unique values of the old array. Indexing with indices relating to vals into that doesn’t really make a whole lot of sense to me…
I’m not aware of such functionality built into Base or any mainstream packages. You can implement it yourself quite easily. Not the necessarily the most efficient, but it should be significantly faster than @Sukera’s solution (which has the advantage of not being overengineered for simple cases):
function unique_ids(itr)
v = Vector{eltype(itr)}()
d = Dict{eltype(itr), Int}()
revid = Vector{Int}()
for val in itr
if haskey(d, val)
push!(revid, d[val])
else
push!(v, val)
d[val] = length(v)
push!(revid, length(v))
end
end
(v, revid)
end