Re: [Numpy-discussion] boolean masks & lists

2007-11-06 Thread Travis E. Oliphant
John Hunter wrote: > A colleague of mine just asked for help with a pesky bug that turned > out to be caused by his use of a list of booleans rather than an array > of booleans as his logical indexing mask. I assume this is a feature > and not a bug, but it certainly surprised him: > > In [58]: ma

Re: [Numpy-discussion] boolean masks & lists

2007-11-06 Thread Timothy Hochberg
On Nov 6, 2007 7:22 AM, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: > Mmm... > It looks as it 'mask' is being inernally converted from > [True, False, False, False, True] > to > [1, 0, 0, 0, 1] > > so your are finally getting > > x[1], x[0], x[0], x[0], x[1] That would be my guess as well. And, i

Re: [Numpy-discussion] boolean masks & lists

2007-11-06 Thread John Hunter
On Nov 6, 2007 8:22 AM, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: > Mmm... > It looks as it 'mask' is being inernally converted from > [True, False, False, False, True] > to > [1, 0, 0, 0, 1] Yep, clearly. The question is: is this the desired behavior because it leads to a "silent failure" for p

Re: [Numpy-discussion] boolean masks & lists

2007-11-06 Thread Lisandro Dalcin
Mmm... It looks as it 'mask' is being inernally converted from [True, False, False, False, True] to [1, 0, 0, 0, 1] so your are finally getting x[1], x[0], x[0], x[0], x[1] On 11/5/07, John Hunter <[EMAIL PROTECTED]> wrote: > A colleague of mine just asked for help with a pesky bug that turned

[Numpy-discussion] boolean masks & lists

2007-11-05 Thread John Hunter
A colleague of mine just asked for help with a pesky bug that turned out to be caused by his use of a list of booleans rather than an array of booleans as his logical indexing mask. I assume this is a feature and not a bug, but it certainly surprised him: In [58]: mask = [True, False, False, Fals