Re: [Numpy-discussion] Fancy indexing with masks

2011-09-27 Thread Han Genuit
2011/9/27 Olivier Delalleau > 2011/9/27 Zbigniew Jędrzejewski-Szmek > >> On 09/22/2011 12:09 PM, Pauli Virtanen wrote: >> > Thu, 22 Sep 2011 08:12:12 +0200, Han Genuit wrote: >> > [clip] >> >> I also noticed that it does strange things when using a list: >> >> >> > c[[True, False, True]] >>

Re: [Numpy-discussion] Fancy indexing with masks

2011-09-27 Thread Olivier Delalleau
2011/9/27 Zbigniew Jędrzejewski-Szmek > On 09/22/2011 12:09 PM, Pauli Virtanen wrote: > > Thu, 22 Sep 2011 08:12:12 +0200, Han Genuit wrote: > > [clip] > >> I also noticed that it does strange things when using a list: > >> > > c[[True, False, True]] > >> array([[3, 4, 5], > >> [0, 1,

Re: [Numpy-discussion] Fancy indexing with masks

2011-09-27 Thread Zbigniew Jędrzejewski-Szmek
On 09/22/2011 12:09 PM, Pauli Virtanen wrote: > Thu, 22 Sep 2011 08:12:12 +0200, Han Genuit wrote: > [clip] >> I also noticed that it does strange things when using a list: >> > c[[True, False, True]] >> array([[3, 4, 5], >> [0, 1, 2], >> [3, 4, 5]]) > > It casts the list with b

Re: [Numpy-discussion] Fancy indexing with masks

2011-09-22 Thread Pauli Virtanen
Thu, 22 Sep 2011 08:12:12 +0200, Han Genuit wrote: [clip] > I also noticed that it does strange things when using a list: > c[[True, False, True]] > array([[3, 4, 5], >[0, 1, 2], >[3, 4, 5]]) It casts the list with booleans to an integer array. Probably shouldn't work like t

Re: [Numpy-discussion] Fancy indexing with masks

2011-09-21 Thread Han Genuit
2011/9/20 Stéfan van der Walt > On Tue, Sep 20, 2011 at 12:43 AM, Robert Kern > wrote: > > If the array is short in a dimension, it gets implicitly continued > > with Falses. You can see this in one dimension: > > [...] > > > I honestly don't know if this is documented or tested anywhere or even

Re: [Numpy-discussion] Fancy indexing with masks

2011-09-20 Thread Stéfan van der Walt
On Tue, Sep 20, 2011 at 12:43 AM, Robert Kern wrote: > If the array is short in a dimension, it gets implicitly continued > with Falses. You can see this in one dimension: [...] > I honestly don't know if this is documented or tested anywhere or even > if this existed in older versions. The beh

Re: [Numpy-discussion] Fancy indexing with masks

2011-09-20 Thread Robert Kern
2011/9/20 Stéfan van der Walt : > Hi all, > > Matthew Brett showed me an interesting code snippet this evening: > > # Construct input data > > In [15]: x > Out[15]: > array([[ 0,  1,  2], >       [ 3,  4,  5], >       [ 6,  7,  8], >       [ 9, 10, 11]]) > > # Fancy indexing with 1D boolean array >

[Numpy-discussion] Fancy indexing with masks

2011-09-19 Thread Stéfan van der Walt
Hi all, Matthew Brett showed me an interesting code snippet this evening: # Construct input data In [15]: x Out[15]: array([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 9, 10, 11]]) # Fancy indexing with 1D boolean array In [16]: x[np.array([True, False, True])] Out[16]: ar