[Numpy-discussion] is this a bug?
jmiller at stsci.edu
Fri Aug 26 12:15:32 CDT 2005
On Fri, 2005-08-26 at 13:24, Stefan Kuzminski wrote:
> >>> from numarray import *
> >>> x = ones(22400,Float)
> >>> print add.reduce(x)
> >>> print add.reduce(x!=0)
> >>> print add.reduce((x!=0).astype(Int))
> it seems like the boolean result of the expression ( middle try )
> causes a problem?
This issue has been discussed before and the general consensus was that
this (somewhat treacherous) behavior should not change.
For array totals (reducing on all axes at once), numarray has a sum()
method which by default does do a type promotion to the "max type of
kind", so integers -> Int64, floats -> Float64, and complexes ->
Complex64 prior to the reduction.
More information about the Numpy-discussion