[Numpy-discussion] Fancy indexing with masks

Olivier Delalleau shish at keba.be
Tue Sep 27 12:32:08 EDT 2011


2011/9/27 Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>

> 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 booleans to an integer array. Probably shouldn't
> > work like that...
> Changing that would require looping over the list first to check if
> everything is an boolean, or maybe just looking at the first few
> elements. Either way pretty ugly. So I guess that the current (slightly
> surprising) behaviour has to stay.
>
>
Ugly implementation is better than ugly behavior IMO.

-=- Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110927/baa444eb/attachment.html>


More information about the NumPy-Discussion mailing list