Re: [Numpy-discussion] argsort question

2006-06-08 Thread Charles R Harris
Robert,Argsort doesn't preserve order by default because quicksort is not a stable sort. Try using the kind="merge" option and see what happens. Or try lexsort, which is targeted at just this sort of sort and usesĀ  merge sort. See the documentation here. http://scipy.org/Numpy_Example_List#head-9f

Re: [Numpy-discussion] argsort question

2006-06-08 Thread Robert Cimrman
Charles R Harris wrote: > Robert, > > Modifying your example gives > > In [3]: import numpy as nm > > In [4]: a = nm.zeros( 1 ) > In [5]: b = nm.arange( 1 ) > In [6]: nm.alltrue( a.argsort(kind="merge" ) == b ) > Out[6]: True Thanks for all the answers! r.

Re: [Numpy-discussion] argsort question

2006-06-08 Thread Charles R Harris
Robert,Modifying your example givesIn [3]: import numpy as nmIn [4]: a = nm.zeros( 1 )In [5]: b = nm.arange( 1 )In [6]: nm.alltrue( a.argsort(kind="merge" ) == b ) Out[6]: TrueOn 6/8/06, Robert Cimrman <[EMAIL PROTECTED]> wrote: Hi all,I have just lost some time to find a bug related to the

Re: [Numpy-discussion] argsort question

2006-06-08 Thread Robert Cimrman
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, althou

Re: [Numpy-discussion] argsort question

2006-06-08 Thread Travis Oliphant
Robert Cimrman wrote: > Hi all, > > 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