Re: [Numpy-discussion] how to use argsort result?

2006-07-13 Thread Eric Firing
> > Would it be reasonable if argsort returned the complete tuple of > indices, so that > A[A.argsort(ax)] would work ? +1 This is the behavior one would naturally expect. Eric - Using Tomcat but need to do more? Need to

Re: [Numpy-discussion] how to use argsort result?

2006-07-13 Thread Pau Gargallo
On 7/13/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Pau Gargallo wrote: > > On 7/12/06, Victoria G. Laidler <[EMAIL PROTECTED]> wrote: > > > >> Hi, > >> > >> Pardon me if I'm reprising an earlier discussion, as I'm new to the list. > >> > >> But is there a reason that this obscure syntax > >>

Re: [Numpy-discussion] how to use argsort result?

2006-07-13 Thread Travis Oliphant
Pau Gargallo wrote: > On 7/12/06, Victoria G. Laidler <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> Pardon me if I'm reprising an earlier discussion, as I'm new to the list. >> >> But is there a reason that this obscure syntax >> >> A[arange(2)[:,newaxis],indexes] >> >> A[arange(A.shape[0])[:,newaxi

Re: [Numpy-discussion] how to use argsort result?

2006-07-13 Thread Pau Gargallo
On 7/12/06, Victoria G. Laidler <[EMAIL PROTECTED]> wrote: > Hi, > > Pardon me if I'm reprising an earlier discussion, as I'm new to the list. > > But is there a reason that this obscure syntax > > A[arange(2)[:,newaxis],indexes] > > A[arange(A.shape[0])[:,newaxis],indexes] > > is preferable to the

Re: [Numpy-discussion] how to use argsort result?

2006-07-12 Thread Victoria G. Laidler
Hi, Pardon me if I'm reprising an earlier discussion, as I'm new to the list. But is there a reason that this obscure syntax A[arange(2)[:,newaxis],indexes] A[arange(A.shape[0])[:,newaxis],indexes] is preferable to the intuitively reasonable thing that the Original Poster did? A[indexes]

Re: [Numpy-discussion] how to use argsort result?

2006-07-11 Thread Stefan van der Walt
On Tue, Jul 11, 2006 at 12:37:23PM +0200, Pau Gargallo wrote: > > Something's not quite right here. The argsort docstring states that: > > > > argsort(a,axis=-1) return the indices into a of the sorted array > > along the given axis, so that take(a,result,axis) is the sorted array. > > > >

Re: [Numpy-discussion] how to use argsort result?

2006-07-11 Thread Pau Gargallo
On 7/11/06, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > On Tue, Jul 11, 2006 at 11:32:48AM +0200, Emanuele Olivetti wrote: > > Hi, > > I don't understand how to use argsort results. I have a 2D matrix and > > I want to sort values in each row and obtain the index array of that > > sorting. Arg

Re: [Numpy-discussion] how to use argsort result?

2006-07-11 Thread Stefan van der Walt
On Tue, Jul 11, 2006 at 11:32:48AM +0200, Emanuele Olivetti wrote: > Hi, > I don't understand how to use argsort results. I have a 2D matrix and > I want to sort values in each row and obtain the index array of that > sorting. Argsort(1) is what I need, but the problem is how to use its > result in

Re: [Numpy-discussion] how to use argsort result?

2006-07-11 Thread Emanuele Olivetti
Wow. I have to study much more indexing. It works pretty well. Just to help indexing newbie like on using your advice: A[arange(A.shape[0])[:,newaxis],indexes] Thanks a lot! Emanuele Pau Gargallo wrote: > here goes a first try: > > A[arange(2)[:,newaxis],indexes]

Re: [Numpy-discussion] how to use argsort result?

2006-07-11 Thread Pau Gargallo
here goes a first try: A[arange(2)[:,newaxis],indexes] pau On 7/11/06, Emanuele Olivetti <[EMAIL PROTECTED]> wrote: > Hi, > I don't understand how to use argsort results. I have a 2D matrix and > I want to sort values in each row and obtain the index array of that > sorting. Argsort(1) is what

[Numpy-discussion] how to use argsort result?

2006-07-11 Thread Emanuele Olivetti
Hi, I don't understand how to use argsort results. I have a 2D matrix and I want to sort values in each row and obtain the index array of that sorting. Argsort(1) is what I need, but the problem is how to use its result in order to obtain a sorted matrix. Here is the simple example: A = array([[2,