[SciPy-user] summation of array elements

Travis E. Oliphant oliphant at ee.byu.edu
Wed Jun 30 16:03:36 CDT 2004

David M. Cooke wrote:
> It's not a problem with Numeric; replacing 'from scipy.xplt import *' with 
> 'from Numeric import *' gives the expected result (1000). The original code 
> gives me the same result as the OP, 232. Using 'from scipy import *' instead 
> also gives me 1000. So there's something funny about importing scipy.xplt.
> So, this works:
> import Numeric
> import RandomArray

Yes, this works if you don't need to use SciPy.

> BUT! putting an 'import scipy' into there makes it not work:
> import Numeric
> import RandomArray
> import scipy

As I said, you should not need to mix and match SciPy and Numeric.

Replace all of your import Numeric code with import scipy and things 
should work fine.

Yes, scipy does change a couple of things about Numeric (check out 
scipy.alter_numeric in the latest CVS for even more interesting changes 
--- like index arrays and coercion rule changes).

For the most part these changes should not cause big issues, but this is 
an example of where you should use SciPy's sum instead of Numeric's sum.

-Travis O.

More information about the SciPy-user mailing list