[Numpy-discussion] boolean masks & lists
John Hunter
jdh2358@gmail....
Mon Nov 5 14:57:11 CST 2007
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])
More information about the Numpy-discussion
mailing list