<br><br><div class="gmail_quote">On Wed, Nov 7, 2012 at 11:24 AM,  <span dir="ltr"><<a href="mailto:josef.pktd@gmail.com" target="_blank">josef.pktd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Tue, Nov 6, 2012 at 9:52 PM, Warren Weckesser<br>
<<a href="mailto:warren.weckesser@gmail.com">warren.weckesser@gmail.com</a>> wrote:<br>
><br>
><br>
> On Tue, Nov 6, 2012 at 8:27 PM, Phillip Feldman<br>
> <<a href="mailto:phillip.m.feldman@gmail.com">phillip.m.feldman@gmail.com</a>> wrote:<br>
>><br>
>> numpy.unique behaves as I would expect for small inputs like the<br>
>> following:<br>
>><br>
>> In [12]: x= [0, 0, 1, 0, 1, 2, 0, 1, 2, 3]<br>
>><br>
>> In [13]: unique(x, return_index=True)<br>
>> Out[13]: (array([0, 1, 2, 3]), array([0, 2, 5, 9], dtype=int64))<br>
>><br>
>> But, when I give it something larger, the return index values do not<br>
>> always correspond to the first occurrences in the input. The documentation<br>
>> is silent on the question of how the return index values are chosen when a<br>
>> given element of x appears more than once. Either the documentation should<br>
>> be<br>
>> clarified, or better yet, the behavior should be changed.<br>
><br>
><br>
><br>
> In fact, it was changed (in the master branch on github) several months ago,<br>
> but there has not yet been a release with the changes.  The sort method that<br>
> np.unique passes to np.argsort is now 'mergesort', and the docstring states<br>
> that the indices returned are for the first occurrences of the unique<br>
> elements.  The new docstring is here:<br>
> <a href="http://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.unique.html#numpy.unique" target="_blank">http://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.unique.html#numpy.unique</a><br>
><br>
> See<br>
> <a href="https://github.com/numpy/numpy/commit/dbf235169ed3386b359caaa9217f5280bf1d6749" target="_blank">https://github.com/numpy/numpy/commit/dbf235169ed3386b359caaa9217f5280bf1d6749</a><br>
> for the commit, and<br>
> <a href="https://github.com/numpy/numpy/blob/master/numpy/lib/arraysetops.py" target="_blank">https://github.com/numpy/numpy/blob/master/numpy/lib/arraysetops.py</a> for the<br>
> latest version of the source.<br>
<br>
</div></div>I think it's in 1.6.2 and it broke return_index for structured dtypes, IIRC.<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br><br>You are correct, Josef, that change is in 1.6.2.  Thanks.<br><br>Warren<br><br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">
Josef<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
><br>
> Warren<br>
><br>
><br>
>><br>
>> _______________________________________________<br>
>> NumPy-Discussion mailing list<br>
>> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
>> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
><br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br>