[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-07-01 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r299279034
 
 

 ##
 File path: python/mxnet/ndarray/numpy/_op.py
 ##
 @@ -900,6 +977,66 @@ def sqrt(x, out=None, **kwargs):
 return _unary_func_helper(x, _npi.sqrt, _np.sqrt, out=out, **kwargs)
 
 
+@set_module('mxnet.ndarray.numpy')
+def sign(x, out=None, **kwargs):
+r"""
 
 Review comment:
   Contents for rendering are from multiarray.py. All overridden already. But 
will try to fix _op.py. Thx!


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-07-01 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298924908
 
 

 ##
 File path: python/mxnet/numpy/multiarray.py
 ##
 @@ -1518,7 +1519,7 @@ def argmax(a, axis=None, out=None):
 axis : int, optional
 By default, the index is into the flattened array, otherwise
 along the specified axis.
-out : array, optional
+out : ndarray, optional
 
 Review comment:
   Fixed. Thx!


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298884276
 
 

 ##
 File path: python/mxnet/_numpy_op_doc.py
 ##
 @@ -16,9 +16,10 @@
 # under the License.
 
 # pylint: skip-file
+# from base import _Null
 
 Review comment:
   Will do. Thx!


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298879806
 
 

 ##
 File path: python/mxnet/symbol/numpy/_symbol.py
 ##
 @@ -1561,6 +1573,44 @@ def sqrt(x, out=None, **kwargs):
 return _unary_func_helper(x, _npi.sqrt, _np.sqrt, out=out, **kwargs)
 
 
+@set_module('mxnet.symbol.numpy')
+def sign(x, out=None, **kwargs):
+r"""
+Returns an element-wise indication of the sign of a number.
+
+The `sign` function returns ``-1 if x < 0, 0 if x==0, 1 if x > 0``. Only 
supports real number.
+
+Parameters
+--
+x : _Symbol or a scalar
+Input values.
+out : _Symbol or None, optional
 
 Review comment:
   Will fix. Thx!


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298879324
 
 

 ##
 File path: python/mxnet/numpy/multiarray.py
 ##
 @@ -2074,6 +2082,252 @@ def sqrt(x, out=None, **kwargs):
 return _mx_nd_np.sqrt(x, out=out, **kwargs)
 
 
+@set_module('mxnet.numpy')
+def tile(x, reps):
+"""
+Construct an array by repeating A the number of times given by reps.
 
 Review comment:
   Good catch! Will fix. 


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298879285
 
 

 ##
 File path: python/mxnet/_numpy_op_doc.py
 ##
 @@ -223,3 +224,144 @@ def _np_dot(a, b, out=None):
 array(29884.)
 """
 pass
+
+
+# def _np_sum(a, axis=None, dtype=None, out=None, keepdims=_Null):
+def _np_sum(a, axis=None, dtype=None, out=None):
+r"""
+sum(a, axis=_Null, dtype=_Null, keepdims=_Null, initial=_Null, out=None)
+
+Sum of array elements over a given axis.
+
+Parameters
+--
+a : ndarray
+Input data.
+axis : None or int, optional
+Axis or axes along which a sum is performed.  The default,
+axis=None, will sum all of the elements of the input array.  If
+axis is negative it counts from the last to the first axis.
+dtype : dtype, optional
+The type of the returned array and of the accumulator in which the
+elements are summed. The default type is 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 `sum` method of sub-classes of
+`ndarray`, however any non-default value will be.  If the
+sub-classes `sum` method does not implement `keepdims` any
+exceptions will be raised.
+initial: Currently only supports None as input, optional
+Starting value for the sum.
+Currently not implemented. Please pass in None if needed.
 
 Review comment:
   I'll rephrase it. Thanks for commenting!


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298879183
 
 

 ##
 File path: python/mxnet/_numpy_op_doc.py
 ##
 @@ -223,3 +224,144 @@ def _np_dot(a, b, out=None):
 array(29884.)
 """
 pass
+
+
+# def _np_sum(a, axis=None, dtype=None, out=None, keepdims=_Null):
+def _np_sum(a, axis=None, dtype=None, out=None):
+r"""
+sum(a, axis=_Null, dtype=_Null, keepdims=_Null, initial=_Null, out=None)
+
+Sum of array elements over a given axis.
+
+Parameters
+--
+a : ndarray
+Input data.
+axis : None or int, optional
+Axis or axes along which a sum is performed.  The default,
+axis=None, will sum all of the elements of the input array.  If
+axis is negative it counts from the last to the first axis.
+dtype : dtype, optional
+The type of the returned array and of the accumulator in which the
+elements are summed. The default type is 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 `sum` method of sub-classes of
+`ndarray`, however any non-default value will be.  If the
+sub-classes `sum` method does not implement `keepdims` any
+exceptions will be raised.
+initial: Currently only supports None as input, optional
+Starting value for the sum.
+Currently not implemented. Please pass in None if needed.
 
 Review comment:
   I think it's trivial problem, but I can fix. Thx for commenting!


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298878825
 
 

 ##
 File path: python/mxnet/_numpy_op_doc.py
 ##
 @@ -223,3 +224,144 @@ def _np_dot(a, b, out=None):
 array(29884.)
 """
 pass
+
+
+# def _np_sum(a, axis=None, dtype=None, out=None, keepdims=_Null):
+def _np_sum(a, axis=None, dtype=None, out=None):
+r"""
+sum(a, axis=_Null, dtype=_Null, keepdims=_Null, initial=_Null, out=None)
+
+Sum of array elements over a given axis.
+
+Parameters
+--
+a : ndarray
+Input data.
+axis : None or int, optional
+Axis or axes along which a sum is performed.  The default,
+axis=None, will sum all of the elements of the input array.  If
+axis is negative it counts from the last to the first axis.
+dtype : dtype, optional
+The type of the returned array and of the accumulator in which the
+elements are summed. The default type is 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 `sum` method of sub-classes of
+`ndarray`, however any non-default value will be.  If the
+sub-classes `sum` method does not implement `keepdims` any
+exceptions will be raised.
+initial: Currently only supports None as input, optional
+Starting value for the sum.
+Currently not implemented. Please pass in None if needed.
+out : ndarray, optional
+Alternative output array in which to place the result. It must have
+the same shape and dtype as the expected output.
+
+Returns
+---
+sum_along_axis : ndarray
+An ndarray with the same shape as `a`, with the specified
+axis removed. If an output array is specified, a reference to
+`out` is returned.
+
+Notes
+-
+Arithmetic is modular when using integer types, and no error is raised on 
overflow.
+The sum of an empty array is the neutral element 0:
+
+>>> a = np.empty(1)
+>>> np.sum(a)
+array(0.)
+
+This function differs from the original `numpy.sum
+`_ in
+the following aspects:
+
+- Input type does not support Python native iterables(list, tuple, ...).
+- "out" param: cannot perform auto type change. out ndarray's dtype must 
be the same as the expected output.
+- "initial" param is not supported yet. Please use None as input.
+
+Examples
+
+>>> a = np.array([0.5, 1.5])
+>>> np.sum(a)
+array(2.)
+>>> a = np.array([0.5, 0.7, 0.2, 1.5])
+>>> np.sum(a, dtype=np.int32)
+array(2, dtype=int32)
+>>> a = np.array([[0, 1], [0, 5]])
+>>> np.sum(a)
+array(6.)
+>>> np.sum(a, axis=0)
+array([0., 6.])
+>>> np.sum(a, axis=1)
+array([1., 5.])
+
+With output ndarray:
+
+>>> a = np.array([[0, 1], [0, 5]])
+>>> b = np.ones((2,), dtype=np.float32)
+>>> np.sum(a, axis = 0, out=b)
+array([0., 6.])
+>>> b
+array([0., 6.])
+
+If the accumulator is too small, overflow occurs:
+
+>>> np.ones(128, dtype=np.int8).sum(dtype=np.int8)
+array(-128, dtype=int8)
+"""
+pass
+
+
+def  _np_copy(a, out=None):
+r"""
+copy(a, out=None)
+
+Return an array copy of the given object.
+
+Parameters
+--
+a : ndarray
+Input data.
+out : ndarray, optional
+Alternative output array in which to place the result. It must have
+the same shape and dtype as the expected output.
+
+Returns
+---
+arr : ndarray
+Array interpretation of `a`.
+
+Notes
+---
+This function differs from the original `numpy.copy
+`_ in
+the following aspects:
+
+- Input type does not support Python native iterables(list, tuple, ...).
+- ``out`` param: cannot perform auto broadcasting. ``out`` ndarray's shape 
must be the same as the expected output.
+- ``out`` param: cannot perform auto type change. ``out`` ndarray's dtype 
must be the same as the expected output.
+- Does not support "order" parameter.
+
+Examples
+
+Create an array x, with a reference y and a copy z:
+
+>>> x = np.array([1, 2, 3])
+>>> y = x
+>>> z = np.copy(x)
+
+Note that, when we modify x, y changes, but not z:
 
 Review comment:
   Will fix. Thx


This is an automated message from the Apache Git Service.
To respond to the message, 

[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298878394
 
 

 ##
 File path: python/mxnet/numpy/multiarray.py
 ##
 @@ -2074,6 +2082,252 @@ def sqrt(x, out=None, **kwargs):
 return _mx_nd_np.sqrt(x, out=out, **kwargs)
 
 
+@set_module('mxnet.numpy')
+def tile(x, reps):
+"""
+Construct an array by repeating A the number of times given by reps.
+
+If `reps` has length ``d``, the result will have dimension of
+``max(d, A.ndim)``.
+
+If ``A.ndim < d``, `A` is promoted to be d-dimensional by prepending new
+axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication,
+or shape (1, 1, 3) for 3-D replication. If this is not the desired
+behavior, promote `A` to d-dimensions manually before calling this
+function.
+
+If ``A.ndim > d``, `reps` is promoted to `A`.ndim by pre-pending 1's to it.
+Thus for an `A` of shape (2, 3, 4, 5), a `reps` of (2, 2) is treated as
+(1, 1, 2, 2).
+
+Parameters
+--
+A : ndarray or scalar
+A input array or a scalar to repeat.
+reps : a single integer or tuple of integers
+The number of repetitions of `A` along each axis.
+
+Returns
+---
+c : ndarray
+The tiled output array.
+
+Examples
+
+>>> a = np.array([0, 1, 2])
+>>> np.tile(a, 2)
+array([0., 1., 2., 0., 1., 2.])
+>>> np.tile(a, (2, 2))
+array([[0., 1., 2., 0., 1., 2.],
+   [0., 1., 2., 0., 1., 2.]])
+>>> np.tile(a, (2, 1, 2))
+array([[[0., 1., 2., 0., 1., 2.]],
+   [[0., 1., 2., 0., 1., 2.]]])
+
+>>> b = np.array([[1, 2], [3, 4]])
+>>> np.tile(b, 2)
+array([[1., 2., 1., 2.],
+   [3., 4., 3., 4.]])
+>>> np.(b, (2, 1))
+array([[1., 2.],
+   [3., 4.],
+   [1., 2.],
+   [3., 4.]])
+
+>>> c = np.array([1,2,3,4])
+>>> np.tile(c,(4,1))
+array([[1., 2., 3., 4.],
+   [1., 2., 3., 4.],
+   [1., 2., 3., 4.],
+   [1., 2., 3., 4.]])
+
+Scalar as input:
+
+>>> np.tile(2, 3)
+array([2, 2, 2]) # repeating integer 2
+
+"""
+return _mx_nd_np.tile(x, reps)
+
+
+@set_module('mxnet.numpy')
+def sign(x, out=None):
+"""
+Returns an element-wise indication of the sign of a number.
+
+The `sign` function returns ``-1 if x < 0, 0 if x==0, 1 if x > 0``. Only 
supports real number.
+
+Parameters
+--
+x : ndarray or a scalar
+Input values.
+out : ndarray or None, optional
+A location into which the result is stored.
+If provided, it must have the same shape and dtype as input ndarray.
+If not provided or `None`, a freshly-allocated array is returned.
+
+Returns
+---
+y : ndarray
+The sign of `x`.
+This is a scalar if `x` is a scalar.
+
+Notes
+---
+This function differs from the original `numpy.sign
+`_ in
+the following aspects:
+
+- Only supports real number as input elements.
+- Input type does not support Python native iterables(list, tuple, ...).
+- ``out`` param: cannot perform auto broadcasting. ``out`` ndarray's shape 
must be the same as the expected output.
+- ``out`` param: cannot perform auto type change. ``out`` ndarray's dtype 
must be the same as the expected output.
+- ``out`` param does not support scalar input case.
+
+Examples
+
+>>> a = np.array([-5., 4.5])
+>>> np.sign(a)
+array([-1.,  1.])
+
+Scalars as input:
+
+>>> np.sign(4.0)
+1.0
+>>> np.sign(0)
+0
+
+Use ``out`` parameter:
+
+>>> b = np.zeros((2, ))
+>>> np.sign(a, out=b)
+array([-1.,  1.])
+>>> b
+array([-1.,  1.])
+
+"""
+return _mx_nd_np.sign(x, out=out)
+
+
+@set_module('mxnet.symbol.numpy')
+def log(x, out=None, **kwargs):
+r"""
+log(x, out=None)
+
+Natural logarithm, element-wise.
+
+The natural logarithm `log` is the inverse of the exponential function,
+so that `log(exp(x)) = x`. The natural logarithm is logarithm in base
+`e`.
+
+Parameters
+--
+x : ndarray
+Input value. Elements must be of real value.
+out : ndarray or None, optional
+A location into which the result is stored.
+If provided, it must have the same shape and dtype as input ndarray.
+If not provided or `None`, a freshly-allocated array is returned.
+
+Returns
+---
+y : ndarray
+The natural logarithm of `x`, element-wise.
+This is a scalar if `x` is a scalar.
+
+Notes
+-
+This function differs from the original `numpy.log
+`_ in
+the following aspects:
+
+- Does not support 

[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298873733
 
 

 ##
 File path: python/mxnet/_numpy_op_doc.py
 ##
 @@ -223,3 +224,144 @@ def _np_dot(a, b, out=None):
 array(29884.)
 """
 pass
+
+
+# def _np_sum(a, axis=None, dtype=None, out=None, keepdims=_Null):
+def _np_sum(a, axis=None, dtype=None, out=None):
+r"""
+sum(a, axis=_Null, dtype=_Null, keepdims=_Null, initial=_Null, out=None)
+
+Sum of array elements over a given axis.
+
+Parameters
+--
+a : ndarray
+Input data.
+axis : None or int, optional
+Axis or axes along which a sum is performed.  The default,
+axis=None, will sum all of the elements of the input array.  If
+axis is negative it counts from the last to the first axis.
+dtype : dtype, optional
+The type of the returned array and of the accumulator in which the
+elements are summed. The default type is 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 `sum` method of sub-classes of
+`ndarray`, however any non-default value will be.  If the
+sub-classes `sum` method does not implement `keepdims` any
+exceptions will be raised.
+initial: Currently only supports None as input, optional
+Starting value for the sum.
+Currently not implemented. Please pass in None if needed.
+out : ndarray, optional
+Alternative output array in which to place the result. It must have
+the same shape and dtype as the expected output.
+
+Returns
+---
+sum_along_axis : ndarray
+An ndarray with the same shape as `a`, with the specified
+axis removed. If an output array is specified, a reference to
+`out` is returned.
+
+Notes
+-
+Arithmetic is modular when using integer types, and no error is raised on 
overflow.
+The sum of an empty array is the neutral element 0:
+
+>>> a = np.empty(1)
+>>> np.sum(a)
+array(0.)
+
+This function differs from the original `numpy.sum
+`_ in
+the following aspects:
+
+- Input type does not support Python native iterables(list, tuple, ...).
+- "out" param: cannot perform auto type change. out ndarray's dtype must 
be the same as the expected output.
 
 Review comment:
   Good catch, will fix


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, copy, tile, argmax, sign, log, degrees

2019-06-30 Thread GitBox
zoeygxy commented on a change in pull request #15382: [numpy][doc-fix] sum, 
copy, tile, argmax, sign, log, degrees
URL: https://github.com/apache/incubator-mxnet/pull/15382#discussion_r298873669
 
 

 ##
 File path: python/mxnet/_numpy_op_doc.py
 ##
 @@ -223,3 +224,144 @@ def _np_dot(a, b, out=None):
 array(29884.)
 """
 pass
+
+
+# def _np_sum(a, axis=None, dtype=None, out=None, keepdims=_Null):
 
 Review comment:
   No. Will fix


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:
us...@infra.apache.org


With regards,
Apache Git Services