[Numpy-discussion] Should bool_ subclass int?
Timothy Hochberg
tim.hochberg@ieee....
Mon Jul 9 14:37:11 CDT 2007
On 7/7/07, Alan G Isaac <aisaac@american.edu> wrote:
>
> On Sat, 7 Jul 2007, Charles R Harris apparently wrote:
> > In [60]: a
> > Out[60]: array([ True, True, True, True], dtype=bool)
> > In [61]: a + a
> > Out[61]: array([ True, True, True, True], dtype=bool)
>
> Yea!
> Behaves like a boolean array.
> And for multiplication to.
> And in boolean matrices, powers work right.
> (I use this.)
>
>
> > In [62]: a + 1
> > Out[62]: array([2, 2, 2, 2])
>
> Yea!
> Coercion to int, as expected.
>
>
> > In [66]: True + True
> > Out[66]: 2
>
> Boo!
> Hopefully Python will "fix" this one day.
It will almost certainly not. And the fact that numpy and Python are
inconsistent this way gives my the creeps.
Why not simply use & and | instead of + and *?
--
. __
. |-\
.
. tim.hochberg@ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070709/55b71fa8/attachment.html
More information about the Numpy-discussion
mailing list