[Numpy-discussion] boolean arrays

Alan G Isaac aisaac@american....
Thu Nov 26 07:55:04 CST 2009


On 11/26/2009 8:20 AM, Nils Wagner wrote:
> a = array(([True,True],[True,True]))
> b = array(([False,False],[False,False]))
> a+b


NumPy's boolean operations are very well behaved.
>>> a = np.array(([True,True],[True,True]))
>>> a+a
array([[ True,  True],
        [ True,  True]], dtype=bool)

Compare Python:

>>> True + True
2

Ugh!
Not fixing this in Python 3 was a big mistake, imo.

Alan Isaac


More information about the NumPy-Discussion mailing list