>> 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
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([(
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
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)
>
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
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
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