[Numpy-discussion] Should bool_ subclass int?
Charles R Harris
charlesr.harris@gmail....
Sat Jul 7 13:32:17 CDT 2007
On 7/7/07, Timothy Hochberg <tim.hochberg@ieee.org> wrote:
>
>
>
> On 7/7/07, Travis Oliphant <oliphant.travis@ieee.org> wrote:
> >
> >
> > >
> > >
> > > On 7/6/07, *Travis Oliphant* <oliphant.travis@ieee.org
> > > <mailto:oliphant.travis@ieee.org>> wrote:
> > >
>
>
<snip>
Here is a link to PEP 285 <http://www.python.org/dev/peps/pep-0285/> where
Guido discusses his reasoning about the bool type. I note that boolean
arrays behave as integers under addition of a scalar, but not under addition
of boolean arrays, where '+' seems to mean 'or'. The latter looks
inconsistent with the Python convention.
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)
In [62]: a + 1
Out[62]: array([2, 2, 2, 2])
In [66]: True + True
Out[66]: 2
Now might be a good time to discuss and document these choices.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070707/179aa365/attachment.html
More information about the Numpy-discussion
mailing list