[SciPy-user] numpy.sum and generator expressions

Neilen Marais nmarais at sun.ac.za
Mon Aug 28 13:44:56 CDT 2006


I have a lot of code that uses numpy.sum with generator expressions:

import numpy as N

a = sum(i for i in xrange(3))

Of course the generator expressions are a little more involved than that.
With numpy 0.9.8 this works as expected:

In [1]: import numpy as N
In [2]: N.sum(i for i in range(3))
Out[2]: 3

but with 1.0b4 I get:

In [14]: N.sum(i for i in range(3))
Out[14]: <generator object at 0x2aaaae5e3248>

Is this the (new?) expected bahaviour, or is it a bug? I hope for the
latter, since I use generators like this quite a bit...


you know its kind of tragic 
we live in the new world
but we've lost the magic
-- Battery 9 (www.battery9.co.za)

More information about the SciPy-user mailing list