tingying2020 commented on a change in pull request #15377: [numpy][doc-fix]
zeros_like, linspace, reciprocal, square, and arcsin
URL: https://github.com/apache/incubator-mxnet/pull/15377#discussion_r298944906
##########
File path: python/mxnet/ndarray/numpy/_op.py
##########
@@ -1012,3 +1052,166 @@ def arctan(x, out=None, **kwargs):
0.7853981633974483
"""
return _unary_func_helper(x, _npi.arctan, _np.arctan, out=out, **kwargs)
+
+
+@set_module('mxnet.ndarray.numpy')
+def reciprocal(x, out=None, **kwargs):
+ r"""
+ reciprocal(x, out=None, dtype=None)
+
+ Return the reciprocal of the argument, element-wise.
+ Calculates ``1/x``.
+
+ Parameters
+ ----------
+ x : ndarray or scalar
+ The values whose reciprocals are required.
+ out : ndarray or None, optional
+ A location into which the result is stored.
+ If provided, it must have the same shape as the input.
+ If not provided or None, a freshly-allocated array is returned.
+
+ Returns
+ -------
+ y : ndarray or scalar
+ Output array is same shape and type as x. This is a scalar if x is a
scalar.
+
+
+ Examples
+ --------
+ >>> np.reciprocal(2.)
+ 0.5
+ >>> x = np.array([1, 2., 3.33])
+ >>> np.reciprocal(x)
+ array([1. , 0.5 , 0.3003003])
+
+ Notes
+ -----
+
+ .. note::
+ This function is not designed to work with integers.
+ For integer arguments with absolute value larger than 1 the result is
+ always zero because of the way Python handles integer division. For
+ integer zero the result is an overflow.
+
+ The output `ndarray` has the same `ctx` as the input `ndarray`.
+
+ This function differs from the original `numpy.reciprocal
+
<https://docs.scipy.org/doc/numpy/reference/generated/numpy.reciprocal.html>`_
in
+ the following aspects:
+
+ - Only support ndarray and scalar now.
+ - `where` argument is not supported.
+ """
+ return _unary_func_helper(x, _npi.reciprocal, _np.reciprocal, out=out,
**kwargs)
+
+
+@set_module('mxnet.ndarray.numpy')
+def square(x, out=None, **kwargs):
+ r"""
+ square(x, out=None, **kwargs)
+
+ Return the element-wise square of the input.
+
+ Parameters
+ ----------
+ x : ndarray or scalar
+ The values whose squares are required.
+ out : ndarray or None, optional
+ A location into which the result is stored.
+ If provided, it must have the same shape as the input.
+ If not provided or None, a freshly-allocated array is returned.
+
+ Returns
+ -------
+ y : ndarray or scalar
+ Output array is same shape and type as x. This is a scalar if x is a
scalar.
+
+
+ Examples
+ --------
+ >>> np.square(2.)
+ 4.0
+ >>> x = np.array([1, 2., -1])
+ >>> np.square(x)
+ array([1., 4., 1.])
+
+ Notes
+ -----
+
+ The output `ndarray` has the same `ctx` as the input `ndarray`.
+
+ This function differs from the original `numpy.square
+ <https://docs.scipy.org/doc/numpy/reference/generated/numpy.square.html>`_
in
+ the following aspects:
+
+ - Only support ndarray and scalar now.
+ - `where` argument is not supported.
+ - Complex input is not supported.
+ """
+ return _unary_func_helper(x, _npi.square, _np.square, out=out, **kwargs)
+
+
+@set_module('mxnet.ndarray.numpy')
+def arcsin(x, out=None, **kwargs):
+ r"""
+ arcsin(x, out=None, **kwargs)
Review comment:
`**kwargs` should not appear
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services