haojin2 commented on a change in pull request #15385: added doc for numpy
operators
URL: https://github.com/apache/incubator-mxnet/pull/15385#discussion_r298889248
##########
File path: python/mxnet/ndarray/numpy/_op.py
##########
@@ -882,3 +906,162 @@ def sqrt(x, out=None, **kwargs):
This function only supports input type of float.
"""
return _unary_func_helper(x, _npi.sqrt, _np.sqrt, out=out, **kwargs)
+
+
+@set_module('mxnet.ndarray.numpy')
+def floor(x, out=None, **kwargs):
+ r"""
+ Return the floor of the input, element-wise.
+ The floor of the scalar `x` is the largest integer `i`, such that
+ `i <= x`. It is often denoted as :math:`\lfloor x \rfloor`.
+
+ Parameters
+ ----------
+ x : ndarray or Python int
+ Input values.
+
+ out : ndarray, None, or tuple of exactly one ndarray, optional
+
+ A location into which the result is stored. If provided, it must have
+ a shape that the inputs broadcast to. If not provided or `None`,
+ a freshly-allocated array is returned. A tuple (possible only as a
+ keyword argument) must have exactly one element. If `x` is a Python
int,
+ nothing will be written to `out`.
+
+ Returns
+ -------
+ y : ndarray
+ The floor of each element in `x`.
+
+ Notes
+ -----
+ Some spreadsheet programs calculate the "floor-towards-zero", in other
+ words ``floor(-2.5) == -2``. MXNet instead uses the definition of
+ `floor` where `floor(-2.5) == -3`.
+
+ This function differs to the original `numpy.floor
+ <https://docs.scipy.org/doc/numpy/reference/generated/numpy.floor.html>`_
in
+ the following aspects:
+
+ - The default value type is `float32` instead of `float64` in numpy.
+ - `a` only supports ndarray or Python int.
+ - `where` can be passed as a keyword parameter, but has no effect.
+ - if a tuple is passed into `out`, it must have exactly one ndarray.
+ The effect is `out` does not support broadcasting.
+
+ Examples
+ --------
+ >>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
+ >>> np.floor(a)
+ array([-2., -2., -1., 0., 1., 1., 2.])
+ """
+ return _unary_func_helper(x, _npi.floor, _np.floor, out=out, **kwargs)
+
+
+@set_module('mxnet.ndarray.numpy')
+def expm1(x, out=None, **kwargs):
+ r"""
+ Calculate ``exp(x) - 1`` for all elements in the array.
+
+ Parameters
+ ----------
+ x : ndarray or Python int
+ Input values.
+
+ out : ndarray, None, or tuple of exactly one ndarray, optional
+
+ A location into which the result is stored. If provided, it must have
+ a shape that the inputs broadcast to. If not provided or `None`,
+ a freshly-allocated array is returned. A tuple (possible only as a
+ keyword argument) must have exactly one element. If `x` is a Python
int,
+ nothing will be written to `out`.
+
+ Returns
+ -------
+ out : ndarray or int
Review comment:
same here, have you made sure that python native floating point numbers does
not work for this op?
----------------------------------------------------------------
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