Thanks Alan and Robert, I probably should have mentioned that I was interested in obtaining the corresponding integer for each value in the array d, in which case the dictionary bit works but would require a further loop to expand.
On 4-Nov-09, at 3:22 PM, Robert Kern wrote: > I'd toss in a sorted() just to keep the mapping stable. Good point. With the return_inverse solution, is unique() guaranteed to give back the same array of unique values in the same (presumably sorted) order? That is, for two arrays A and B which have elements only drawn from a set S, is all(unique(A) == unique(B)) guaranteed? The code is a quite clever and a bit hard to follow, but it *looks* like it will provide a stable mapping since it's using a sort. David _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion