Re: [Numpy-discussion] yet another indexing question

2011-10-17 Thread Chris.Barker
On 10/14/11 5:04 AM, Neal Becker wrote: > suppose I have: > > In [10]: u > Out[10]: > array([[0, 1, 2, 3, 4], > [5, 6, 7, 8, 9]]) > > And I have a vector v: > v = np.array ((0,1,0,1,0)) > > I want to form an output vector which selects items from u where v is the > index > of the row of

Re: [Numpy-discussion] yet another indexing question

2011-10-14 Thread Neal Becker
Fabrice Silva wrote: > Le vendredi 14 octobre 2011 à 08:04 -0400, Neal Becker a écrit : >> suppose I have: >> >> In [10]: u >> Out[10]: >> array([[0, 1, 2, 3, 4], >>[5, 6, 7, 8, 9]]) >> >> And I have a vector v: >> v = np.array ((0,1,0,1,0)) >> >> I want to form an output vector which

Re: [Numpy-discussion] yet another indexing question

2011-10-14 Thread Fabrice Silva
Le vendredi 14 octobre 2011 à 08:04 -0400, Neal Becker a écrit : > suppose I have: > > In [10]: u > Out[10]: > array([[0, 1, 2, 3, 4], >[5, 6, 7, 8, 9]]) > > And I have a vector v: > v = np.array ((0,1,0,1,0)) > > I want to form an output vector which selects items from u where v is th

Re: [Numpy-discussion] yet another indexing question

2011-10-14 Thread Jean-Luc Menut
What about a=arange(len(v)) w=u[v,a] ? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] yet another indexing question

2011-10-14 Thread Warren Weckesser
On Fri, Oct 14, 2011 at 7:04 AM, Neal Becker wrote: > suppose I have: > > In [10]: u > Out[10]: > array([[0, 1, 2, 3, 4], > [5, 6, 7, 8, 9]]) > > And I have a vector v: > v = np.array ((0,1,0,1,0)) > > I want to form an output vector which selects items from u where v is the > index > of t

[Numpy-discussion] yet another indexing question

2011-10-14 Thread Neal Becker
suppose I have: In [10]: u Out[10]: array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) And I have a vector v: v = np.array ((0,1,0,1,0)) I want to form an output vector which selects items from u where v is the index of the row of u to be selected. In the above example, I want: w = [0,6,2,8,4