[Numpy-discussion] strange behavior of numpy.unique

Phillip Feldman phillip.m.feldman at gmail.com
Tue Nov 6 21:27:21 EST 2012

numpy.unique behaves as I would expect for small inputs like the following:

In [12]: x= [0, 0, 1, 0, 1, 2, 0, 1, 2, 3]

In [13]: unique(x, return_index=True)
Out[13]: (array([0, 1, 2, 3]), array([0, 2, 5, 9], dtype=int64))

But, when I give it something larger, the return index values do not always
correspond to the first occurrences in the input. The documentation is
silent on the question of how the return index values are chosen when a
given element of x appears more than once. Either the documentation should
clarified, or better yet, the behavior should be changed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20121106/36065c47/attachment.html>

More information about the NumPy-Discussion mailing list