[Numpy-discussion] Conditional update of recarray field

2012-11-28 Thread Bartosz
Hi, I try to update values in a single field of numpy record array based on a condition defined in another array. I found that that the result depends on the order in which I apply the boolean indices/field names. For example: cond = np.zeros(5, dtype=np.bool) cond[2:] = True X =

Re: [Numpy-discussion] Conditional update of recarray field

2012-11-28 Thread Francesc Alted
On 11/28/12 1:47 PM, Bartosz wrote: Hi, I try to update values in a single field of numpy record array based on a condition defined in another array. I found that that the result depends on the order in which I apply the boolean indices/field names. For example: cond = np.zeros(5,

Re: [Numpy-discussion] Conditional update of recarray field

2012-11-28 Thread Bartosz
Thanks for answer, Francesc. I understand now that fancy indexing returns a copy of a recarray. Is it also true for standard ndarrays? If so, I do not understand why X['a'][cond]=-1 should work. Cheers, Bartosz On Wed 28 Nov 2012 03:05:37 PM CET, Francesc Alted wrote: On 11/28/12 1:47 PM,

Re: [Numpy-discussion] Conditional update of recarray field

2012-11-28 Thread Francesc Alted
Hey Bartosz, On 11/28/12 3:26 PM, Bartosz wrote: Thanks for answer, Francesc. I understand now that fancy indexing returns a copy of a recarray. Is it also true for standard ndarrays? If so, I do not understand why X['a'][cond]=-1 should work. Yes, that's a good question. No, in this case

Re: [Numpy-discussion] Conditional update of recarray field

2012-11-28 Thread Bartosz
I got it. Thanks! Now I see why this is non-trivial to fix it. However, it might be also a source of very-hard-to-find bugs. It might be worth discussing this non-intuitive example in the documentation. Cheers, Bartosz Thanks for answer, Francesc. I understand now that fancy indexing