From: Charles R H. <cha...@gm...> - 2006-08-27 19:58:36
|
Hi, The problem seems to arise in the array constructor, which treats the generator as a python object and creates an array containing that object. So, do we want the possibility of an array of generators or should we interpret it as a sort of list? I vote for that latter. Chuck On 8/27/06, Charles R Harris <cha...@gm...> wrote: > > Hi Christopher, > > On 8/27/06, Charles R Harris <cha...@gm...> wrote: > > > > Hi, > > > > On 8/27/06, lis...@ma... <lis...@ma...> wrote: > > > > > > -----BEGIN PGP SIGNED MESSAGE----- > > > Hash: SHA1 > > > > > > It seems like numpy.sum breaks generator expressions: > > > > > > In [1]: sum(i*i for i in range(10)) > > > Out[1]: 285 > > > > > > In [2]: from numpy import sum > > > > > > In [3]: sum(i*i for i in range(10)) > > > Out[3]: <generator object at 0x10eca58> > > > > > > Is this intentional? If so, how do I get the behaviour that I am > > > after? > > > > > > > > > In [3]: sum([i*i for i in range(10)]) > > Out[3]: 285 > > > > Chuck > > > > The numarray.sum also fails to accept a generator as an argument. Because > python does and the imported sum overwrites it, we should probably check the > argument type and make it do the right thing. > > Chuck > > > |