[Numpy-discussion] argsort question

Robert Cimrman cimrman3 at ntc.zcu.cz
Thu Jun 8 10:38:30 CDT 2006


Travis Oliphant wrote:
> Robert Cimrman wrote:
> 
>>I have just lost some time to find a bug related to the fact, that 
>>argsort does not preserve the order of an array that is already sorted, 
>>see the example below. For me, it would be sufficient to mention this 
>>fact in the docstring, although having order preserving argsort is also 
>>an option :). What do the developers think?
>>
>>In [33]:a = nm.zeros( 10000 )
>>In [34]:b = nm.arange( 10000 )
>>In [35]:nm.alltrue( nm.argsort( a ) == b )
>>Out[35]:False
>>
> You want a "stable" sorting algorithm like the "mergesort".  Use the 
> argsort method with the mergesoret kind option:
> 
> a.argsort(kind='merge')

Thank you, Travis. Now I see that the function argsort in oldnumeric.py 
has different docstring that the array method argsort, which mentions 
the 'kind' keyword argument. Is the argsort function going to be 
deprecated? If no, is it possible to synchronize the docstrings? Also a 
note (in docs) which algorithm is stable would be handy.

regards,
r.




More information about the Numpy-discussion mailing list