Re: [Numpy-discussion] sum and prod

2012-09-09 Thread Han Genuit
>> Is the difference between prod and sum intentional? I would expect >> that numpy.prod would also work on a generator, just like numpy.sum. > > > > Whatever the correct result may be, I would expect them to have the same > behavior with respect to a generator argument. > I found out that np.sum

Re: [Numpy-discussion] sum and prod

2012-09-09 Thread nicky van foreest
Thanks for your hints. NIcky On 9 September 2012 00:30, eat wrote: > Hi, > > On Sun, Sep 9, 2012 at 12:56 AM, nicky van foreest > wrote: >> >> Hi, >> >> I ran the following code: >> >> args = np.array([4,8]) >> print np.sum( (arg > 0) for arg in args) >> print np.sum([(

Re: [Numpy-discussion] sum and prod

2012-09-09 Thread nicky van foreest
On 9 September 2012 00:10, Warren Weckesser wrote: > > > On Sat, Sep 8, 2012 at 4:56 PM, nicky van foreest > wrote: >> >> Hi, >> >> I ran the following code: >> >> args = np.array([4,8]) >> print np.sum( (arg > 0) for arg in args) >> print np.sum([(arg > 0) for arg in args

Re: [Numpy-discussion] sum and prod

2012-09-08 Thread eat
Hi, On Sun, Sep 9, 2012 at 12:56 AM, nicky van foreest wrote: > Hi, > > I ran the following code: > > args = np.array([4,8]) > print np.sum( (arg > 0) for arg in args) > print np.sum([(arg > 0) for arg in args]) > print np.prod( (arg > 0) for arg in args) >

Re: [Numpy-discussion] sum and prod

2012-09-08 Thread Warren Weckesser
On Sat, Sep 8, 2012 at 4:56 PM, nicky van foreest wrote: > Hi, > > I ran the following code: > > args = np.array([4,8]) > print np.sum( (arg > 0) for arg in args) > print np.sum([(arg > 0) for arg in args]) > print np.prod( (arg > 0) for arg in args) > print

Re: [Numpy-discussion] sum and prod

2012-09-08 Thread Han Genuit
Hi, Maybe try something like this? >>> args = np.array([4,8]) >>> np.prod(args > 0) 1 >>> np.sum(args > 0) 2 Cheers, Han ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] sum and prod

2012-09-08 Thread nicky van foreest
Hi, I ran the following code: args = np.array([4,8]) print np.sum( (arg > 0) for arg in args) print np.sum([(arg > 0) for arg in args]) print np.prod( (arg > 0) for arg in args) print np.prod([(arg > 0) for arg in args]) with this result: 2 1 at 0x1c7041