Product of an empty sequence
Alan G Isaac
aisaac at american.edu
Thu Oct 19 08:07:51 CDT 2006
On Thu, 19 Oct 2006, Ivan Vilata i Balaguer apparently wrote:
>>>> numpy.prod(())
> 1.0
> Wouldn't be 0.0 a more natural answer?
I think it must be 1 or a TypeError. E.g.,
http://docs.python.org/lib/built-in-funcs.html#reduce
reduce(function, sequence[, initializer])
Apply function of two arguments cumulatively to the
items of sequence, from left to right, so as to reduce
the sequence to a single value. For example,
reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates
((((1+2)+3)+4)+5). The left argument, x, is the
accumulated value and the right argument, y, is the
update value from the sequence. If the optional
initializer is present, it is placed before the items of
the sequence in the calculation, and serves as a default
when the sequence is empty. If initializer is not given
and sequence contains only one item, the first item is
returned.
hth,
Alan Isaac
(just a user)
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
More information about the Numpy-discussion
mailing list