[Numpy-discussion] numpy.prod() vs. numpy.product()

Bill Baxter wbaxter at gmail.com
Mon Jul 24 18:30:22 CDT 2006


I can't answer why, but in oldnumeric.py, you can see there's two
different fuctions with basically identical code, so yes they are
distinct, but no they are not different.  Seems like prod could be
replaced by prod=product.

def product (x, axis=0, dtype=None):
    """Product of the array elements over the given axis."""
    try:
        prod = x.prod
    except AttributeError:
        return _wrapit(x, 'prod', axis, dtype)
    return prod(axis, dtype)

def prod(a, axis=0, dtype=None):
    """Return the product of the elements along the given axis
    """
    try:
        prod = a.prod
    except AttributeError:
        return _wrapit(a, 'prod', axis, dtype)
    return prod(axis, dtype)


--bb

On 7/25/06, Sebastian Haase <haase at msg.ucsf.edu> wrote:
> Hi,
> Are numpy.product() and numpy.prod()
> doing the exact same thing ? If yes, why are they pointing to two different
> functions ?
> >>> N.prod
> <function prod at 0x43cef56c>
> >>> N.product
> <function product at 0x43cef304>
>
> Thanks,
> Sebastian Haase
>




More information about the Numpy-discussion mailing list