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]: mask = [True, False, False, False, True] > > In [59]: maska = n.array(mask, n.bool) > > In [60]: x = arange(5) > > In [61]: x[mask] > Out[61]: array([1, 0, 0, 0, 1]) > > In [62]: x[maska] > Out[62]: array([0, 4]) > The issues is how to determine what behavior is desired and how to manage that with all the possibilities.
Right now the rule is that only boolean arrays are treated as masks and integer arrays mean indexing. Lists are always interpreted as integer indexing (except in certain special cases where the list has slice objects in it). Changing this to something like: lists are interpreted either as boolean or integer arrays, may be reasonable, but I don't see how we can change it until 1.1 because the rule has already been specified and is consistent if not obvious in this simple case. The question is: is anybody using boolean lists specifically according to the rule in place now? -Travis _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
