<br><br><div class="gmail_quote">On Wed, May 30, 2012 at 4:59 AM, Nathaniel Smith <span dir="ltr"><<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.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, May 29, 2012 at 7:42 PM, Charles R Harris<br>
<<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
><br>
><br>
> On Mon, May 28, 2012 at 9:18 PM, <<a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a>> wrote:<br>
>><br>
>><br>
>> <a href="https://github.com/numpy/numpy/commit/74b9f5eef8fac643bf9012dbb2ac6b4b19f46892" target="_blank">https://github.com/numpy/numpy/commit/74b9f5eef8fac643bf9012dbb2ac6b4b19f46892</a><br>
>> broke return_inverse for structured arrays, because of the use of<br>
>> mergesort<br>
>><br>
>> I'm using structured dtypes to get uniques and return_inverse by rows<br>
>><br>
>> >>> groups = np.random.randint(0,4,size=(10,2))<br>
>> >>> groups_ = groups.view([('',groups.dtype)]*groups.shape[1]).flatten()<br>
>> >>> groups<br>
>> array([[0, 2],<br>
>>       [1, 2],<br>
>>       [1, 1],<br>
>>       [3, 1],<br>
>>       [3, 1],<br>
>>       [2, 1],<br>
>>       [1, 0],<br>
>>       [3, 3],<br>
>>       [3, 2],<br>
>>       [0, 0]])<br>
>> >>> groups_<br>
>> array([(0, 2), (1, 2), (1, 1), (3, 1), (3, 1), (2, 1), (1, 0), (3, 3),<br>
>>       (3, 2), (0, 0)],<br>
>>      dtype=[('f0', '<i4'), ('f1', '<i4')])<br>
>><br>
>> >>> np.argsort(groups_)<br>
>> array([9, 0, 6, 2, 1, 5, 4, 3, 8, 7])<br>
>><br>
>> >>> np.argsort(groups_, kind='mergesort')<br>
>> Traceback (most recent call last):<br>
>>  File "<stdin>", line 1, in <module><br>
>>  File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line<br>
>> 679, in argsort<br>
>>    return argsort(axis, kind, order)<br>
>> TypeError: requested sort not available for type<br>
>><br>
>> >>> uni, uni_idx, uni_inv = np.unique(groups_, return_index=True,<br>
>> >>> return_inverse=True)<br>
>> >>> uni_inv<br>
>> array([1, 4, 3, 6, 6, 5, 2, 8, 7, 0])<br>
>><br>
>> exception in numpy 1.6.2rc2 (as reported by Debian for statsmodels)<br>
>><br>
><br>
> I've been putting of, um, planning to implement the different sort kinds for<br>
> object/structured arrays for a while, sounds like it needs to get done.<br>
<br>
</div></div>So I guess this is a 1.6.1 -> 1.6.2 regression, and presumably we<br>
won't be landing any new sort implementations in the 1.6 branch.<br>
Should we be thinking about reverting this and releasing a 1.6.3? (I<br>
don't know if it's worth it, but it seems like something we should<br>
think about either way.)<br>
<br>
Same question applies to 1.7 too -- obviously the change to unique()<br>
is a good one, but maybe it has to wait until mergesort can handle<br>
structured dtypes?<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br>Should definitely be reverted if a 1.6.3 goes out.<br><br>Chuck <br></div><br></div>