[Numpy-discussion] is this a bug?

Todd Miller jmiller at stsci.edu
Fri Aug 26 12:15:32 EDT 2005


On Fri, 2005-08-26 at 13:24, Stefan Kuzminski wrote:
> >>> from numarray import *
> >>> x = ones(22400,Float)
> >>> print add.reduce(x)
> 22400.0
> >>> print add.reduce(x!=0)
> -128
> >>> print add.reduce((x!=0).astype(Int))
> 22400
> 
> 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.

Regards,
Todd





More information about the NumPy-Discussion mailing list