[Numpy-discussion] ufunc oddities

Charles R Harris charlesr.harris@gmail....
Sat May 24 22:24:24 CDT 2008


On Sat, May 24, 2008 at 9:21 PM, Alan G Isaac <aisaac@american.edu> wrote:

> On Sat, 24 May 2008, Keith Goodman apparently wrote:
> >>> x = np.array([True, True], dtype=bool)
> >>> x.sum()
> >    2
>
>
>
> If you want bools, change the accumulator dtype::
>
>    >>> x.sum(dtype=bool)


Shouldn't that be the other way round? If you want integers, do
x.sum(dtype=int). Ints don't sum in float64 by default.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080524/058543eb/attachment.html 


More information about the Numpy-discussion mailing list