You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/07/01 04:49:11 UTC

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #15388: Doc

hzfan commented on a change in pull request #15388: Doc
URL: https://github.com/apache/incubator-mxnet/pull/15388#discussion_r298879802
 
 

 ##########
 File path: python/mxnet/_numpy_op_doc.py
 ##########
 @@ -176,3 +176,122 @@ def _np_cumsum(a, axis=None, dtype=None, out=None):
         `axis` is not None or `a` is a 1-d array.
     """
     pass
+
+def _np_prod(a, axis=None, dtype=None, out=None, keepdims=None):
+    r"""
+    prod(a, axis=None, dtype=None, keepdims=_Null, initial=None, out=None)
+
+    Return the product of array elements over a given axis.
+    
+    Parameters
+    ----------
+    a : ndarray
+        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 all the elements in the
+        input array. If axis is negative it counts from the last to the
+        first axis.
+    
+        If axis is a tuple of ints, a product is performed on all of the
+        axes specified in the tuple instead of a single axis or all the
+        axes as before.
+    dtype : dtype, optional
+        The type of the returned array, as well as of the accumulator in
+        which the elements are multiplied.  Default is numpy.float32.
+    keepdims : bool, optional
+        If this is set to True, the axes which are reduced are left in the
+        result as dimensions with size one. With this option, the result
+        will broadcast correctly against the input array.
+    
+        If the default value is passed, then `keepdims` will not be
+        passed through to the `prod` method of sub-classes of
+        `ndarray`, however any non-default value will be.  If the
+        sub-class' method does not implement `keepdims` any
+        exceptions will be raised.
+    initial : None, optional
+        Must be None.
+    out : ndarray, optional
+        Alternative output array in which to place the result. It must have
+        the same shape as the expected output and the same type.
+    
+    Returns
+    -------
+    product_along_axis : ndarray, see `dtype` parameter above.
+
+    Notes
+    -----
+    Arithmetic is modular when using integer types, and no error is
+    raised on overflow.  That means that, on a 32-bit platform:
+    
+    >>> x = np.array([536870910, 536870910, 536870910, 536870910]).astype('int')
+    >>> np.prod(x) 
+    array(0)
+ 
+    This function differs to the original numpy.prod in the following aspects:
+        
+        - Do not support empty ndarray or scalar as input.
+        - Keepdims must be 0 or 1. Otherwise, an error will raise.
+        - Can't cast type automatically.
+
+    Examples
+    --------
+    By default, calculate the product of all elements:
+    
+    >>> x = np.array([1.,2.])
+    >>> np.prod(x)
+    array(2.)
+    
+    Even when the input array is two-dimensional:
+    
+    >>> x = np.array([[1.,2.],[3.,4.]])
+    >>> np.prod(x)
+    array(24.)
+    
+    But we can also specify the axis over which to multiply:
+
+    >>> x = np.array([[1.,2.],[3.,4.]])
 
 Review comment:
   same as before, space after comma is recommended

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services