|
From: Todd M. <jm...@st...> - 2005-08-26 19:14:19
|
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 |