MCPcopy Create free account
hub / github.com/numpy/numpy / prod

Function prod

numpy/core/fromnumeric.py:2980–3101  ·  view source on GitHub ↗

Return the product of array elements over a given axis. Parameters ---------- a : array_like Input data. axis : None or int or tuple of ints, optional Axis or axes along which a product is performed. The default, axis=None, will calculate the product of

(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
         initial=np._NoValue, where=np._NoValue)

Source from the content-addressed store, hash-verified

2978
2979@array_function_dispatch(_prod_dispatcher)
2980def prod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
2981 initial=np._NoValue, where=np._NoValue):
2982 """
2983 Return the product of array elements over a given axis.
2984
2985 Parameters
2986 ----------
2987 a : array_like
2988 Input data.
2989 axis : None or int or tuple of ints, optional
2990 Axis or axes along which a product is performed. The default,
2991 axis=None, will calculate the product of all the elements in the
2992 input array. If axis is negative it counts from the last to the
2993 first axis.
2994
2995 .. versionadded:: 1.7.0
2996
2997 If axis is a tuple of ints, a product is performed on all of the
2998 axes specified in the tuple instead of a single axis or all the
2999 axes as before.
3000 dtype : dtype, optional
3001 The type of the returned array, as well as of the accumulator in
3002 which the elements are multiplied. The dtype of `a` is used by
3003 default unless `a` has an integer dtype of less precision than the
3004 default platform integer. In that case, if `a` is signed then the
3005 platform integer is used while if `a` is unsigned then an unsigned
3006 integer of the same precision as the platform integer is used.
3007 out : ndarray, optional
3008 Alternative output array in which to place the result. It must have
3009 the same shape as the expected output, but the type of the output
3010 values will be cast if necessary.
3011 keepdims : bool, optional
3012 If this is set to True, the axes which are reduced are left in the
3013 result as dimensions with size one. With this option, the result
3014 will broadcast correctly against the input array.
3015
3016 If the default value is passed, then `keepdims` will not be
3017 passed through to the `prod` method of sub-classes of
3018 `ndarray`, however any non-default value will be. If the
3019 sub-class' method does not implement `keepdims` any
3020 exceptions will be raised.
3021 initial : scalar, optional
3022 The starting value for this product. See `~numpy.ufunc.reduce` for details.
3023
3024 .. versionadded:: 1.15.0
3025
3026 where : array_like of bool, optional
3027 Elements to include in the product. See `~numpy.ufunc.reduce` for details.
3028
3029 .. versionadded:: 1.17.0
3030
3031 Returns
3032 -------
3033 product_along_axis : ndarray, see `dtype` parameter above.
3034 An array shaped as `a` but with the specified axis removed.
3035 Returns a reference to `out` if specified.
3036
3037 See Also

Callers 3

_is_empty_2dFunction · 0.90
productFunction · 0.70
testProdMethod · 0.50

Calls 1

_wrapreductionFunction · 0.85

Tested by 1

testProdMethod · 0.40