Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement dpnp.rint #1537

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions dpnp/dpnp_iface_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def all(x, /, axis=None, out=None, keepdims=False, *, where=True):

Returns
-------
dpnp.ndarray
An array with a data type of `bool`
containing the results of the logical AND reduction.
out : dpnp.ndarray
An array with a data type of `bool`
containing the results of the logical AND reduction.

Limitations
-----------
Expand Down Expand Up @@ -198,7 +198,7 @@ def any(x, /, axis=None, out=None, keepdims=False, *, where=True):

Returns
-------
dpnp.ndarray
out : dpnp.ndarray
An array with a data type of `bool`
containing the results of the logical OR reduction.

Expand Down Expand Up @@ -276,7 +276,7 @@ def equal(
Returns
-------
out : dpnp.ndarray
Output array of bool type, element-wise comparison of `x1` and `x2`.
Output array of bool type, element-wise comparison of `x1` and `x2`.

Limitations
-----------
Expand Down Expand Up @@ -352,7 +352,7 @@ def greater(
Returns
-------
out : dpnp.ndarray
Output array of bool type, element-wise comparison of `x1` and `x2`.
Output array of bool type, element-wise comparison of `x1` and `x2`.

Limitations
-----------
Expand Down Expand Up @@ -422,7 +422,7 @@ def greater_equal(
Returns
-------
out : dpnp.ndarray
Output array of bool type, element-wise comparison of `x1` and `x2`.
Output array of bool type, element-wise comparison of `x1` and `x2`.

Limitations
-----------
Expand Down Expand Up @@ -678,7 +678,7 @@ def less(
Returns
-------
out : dpnp.ndarray
Output array of bool type, element-wise comparison of `x1` and `x2`.
Output array of bool type, element-wise comparison of `x1` and `x2`.

Limitations
-----------
Expand Down Expand Up @@ -748,7 +748,7 @@ def less_equal(
Returns
-------
out : dpnp.ndarray
Output array of bool type, element-wise comparison of `x1` and `x2`.
Output array of bool type, element-wise comparison of `x1` and `x2`.

Limitations
-----------
Expand Down Expand Up @@ -818,8 +818,8 @@ def logical_and(
Returns
-------
out : dpnp.ndarray
Boolean result of the logical AND operation applied to the elements
of `x1` and `x2`; the shape is determined by broadcasting.
Boolean result of the logical AND operation applied to the elements
of `x1` and `x2`; the shape is determined by broadcasting.

Limitations
-----------
Expand Down Expand Up @@ -891,8 +891,8 @@ def logical_not(
Returns
-------
out : dpnp.ndarray
Boolean result with the same shape as `x` of the NOT operation
on elements of `x`.
Boolean result with the same shape as `x` of the NOT operation
on elements of `x`.

Limitations
-----------
Expand Down Expand Up @@ -953,8 +953,8 @@ def logical_or(
Returns
-------
out : dpnp.ndarray
Boolean result of the logical OR operation applied to the elements
of `x1` and `x2`; the shape is determined by broadcasting.
Boolean result of the logical OR operation applied to the elements
of `x1` and `x2`; the shape is determined by broadcasting.

Limitations
-----------
Expand Down Expand Up @@ -1027,8 +1027,8 @@ def logical_xor(
Returns
-------
out : dpnp.ndarray
Boolean result of the logical XOR operation applied to the elements
of `x1` and `x2`; the shape is determined by broadcasting.
Boolean result of the logical XOR operation applied to the elements
of `x1` and `x2`; the shape is determined by broadcasting.

Limitations
-----------
Expand Down
111 changes: 99 additions & 12 deletions dpnp/dpnp_iface_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"power",
"prod",
"remainder",
"rint",
"round",
"sign",
"subtract",
Expand Down Expand Up @@ -145,7 +146,7 @@ def absolute(x, /, out=None, *, where=True, dtype=None, subok=True, **kwargs):

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
An array containing the absolute value of each element in `x`.

Limitations
Expand Down Expand Up @@ -219,7 +220,7 @@ def add(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
The sum of `x1` and `x2`, element-wise.

Limitations
Expand Down Expand Up @@ -275,6 +276,11 @@ def around(x, /, decimals=0, out=None):

For full documentation refer to :obj:`numpy.around`.

Returns
-------
out : dpnp.ndarray
The rounded value of elements of the array.

Limitations
-----------
Parameter `x` is only supported as either :class:`dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`.
Expand All @@ -284,7 +290,9 @@ def around(x, /, decimals=0, out=None):

See Also
--------
:obj:`dpnp.round` : equivalent function; see for details.
:obj:`dpnp.round` : Equivalent function; see for details.
vtavana marked this conversation as resolved.
Show resolved Hide resolved
:obj:`dpnp.ndarray.round` : Equivalent function.
:obj:`dpnp.rint` : Round elements of the array to the nearest integer.
:obj:`dpnp.ceil` : Compute the ceiling of the input, element-wise.
:obj:`dpnp.floor` : Return the floor of the input, element-wise.
:obj:`dpnp.trunc` : Return the truncated value of the input, element-wise.
Expand Down Expand Up @@ -659,7 +667,7 @@ def divide(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
The quotient `x1/x2`, element-wise.

Limitations
Expand Down Expand Up @@ -865,6 +873,11 @@ def floor_divide(

For full documentation refer to :obj:`numpy.floor_divide`.

Returns
-------
out : dpnp.ndarray
The floordivide of each element of `x`.

Limitations
-----------
Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray`
Expand Down Expand Up @@ -1215,6 +1228,11 @@ def mod(

For full documentation refer to :obj:`numpy.mod`.

Returns
-------
out : dpnp.ndarray
The element-wise remainder of the quotient `floor_divide(x1, x2)`.

Limitations
-----------
Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray`
Expand Down Expand Up @@ -1298,7 +1316,7 @@ def multiply(

Returns
-------
y : {dpnp.ndarray, scalar}
out : {dpnp.ndarray, scalar}
The product of `x1` and `x2`, element-wise.

Limitations
Expand Down Expand Up @@ -1503,7 +1521,7 @@ def negative(
Returns
-------
out : dpnp.ndarray
The numerical negative of each element of `x`.
The numerical negative of each element of `x`.

Limitations
-----------
Expand Down Expand Up @@ -1555,7 +1573,7 @@ def power(x1, x2, /, out=None, *, where=True, dtype=None, subok=True, **kwargs):

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
The bases in `x1` raised to the exponents in `x2`.

Limitations
Expand Down Expand Up @@ -1702,6 +1720,64 @@ def prod(
)


def rint(
x,
/,
out=None,
*,
order="K",
where=True,
dtype=None,
subok=True,
**kwargs,
):
"""
Round elements of the array to the nearest integer.

For full documentation refer to :obj:`numpy.rint`.

Returns
-------
out : dpnp.ndarray
The rounded value of elements of the array to the nearest integer.

Limitations
-----------
Parameter `x` is only supported as either :class:`dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`.
Parameters `where`, `dtype` and `subok` are supported with their default values.
Keyword argument `kwargs` is currently unsupported.
Otherwise the function will be executed sequentially on CPU.
Input array data types are limited by supported DPNP :ref:`Data types`.

See Also
--------
:obj:`dpnp.round` : Evenly round to the given number of decimals.
:obj:`dpnp.ceil` : Compute the ceiling of the input, element-wise.
:obj:`dpnp.floor` : Return the floor of the input, element-wise.
:obj:`dpnp.trunc` : Return the truncated value of the input, element-wise.

Examples
--------
>>> import dpnp as np
>>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
>>> np.rint(a)
array([-2., -2., -0., 0., 2., 2., 2.])

"""

return check_nd_call_func(
numpy.rint,
dpnp_round,
x,
out=out,
where=where,
order=order,
dtype=dtype,
subok=subok,
**kwargs,
)


def remainder(
x1,
x2,
Expand All @@ -1719,6 +1795,11 @@ def remainder(

For full documentation refer to :obj:`numpy.remainder`.

Returns
-------
out : dpnp.ndarray
The element-wise remainder of the quotient `floor_divide(x1, x2)`.

Limitations
-----------
Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray`
Expand Down Expand Up @@ -1773,6 +1854,11 @@ def round(x, decimals=0, out=None):

For full documentation refer to :obj:`numpy.round`.

Returns
-------
out : dpnp.ndarray
The rounded value of elements of the array.

Limitations
-----------
Parameter `x` is only supported as either :class:`dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`.
Expand All @@ -1782,7 +1868,9 @@ def round(x, decimals=0, out=None):

See Also
--------
:obj:`dpnp.around` : equivalent function; see for details.
:obj:`dpnp.around` : Equivalent function; see for details.
:obj:`dpnp.ndarray.round` : Equivalent function.
:obj:`dpnp.rint` : Round elements of the array to the nearest integer.
:obj:`dpnp.ceil` : Compute the ceiling of the input, element-wise.
:obj:`dpnp.floor` : Return the floor of the input, element-wise.
:obj:`dpnp.trunc` : Return the truncated value of the input, element-wise.
Expand Down Expand Up @@ -1832,7 +1920,7 @@ def sign(
Returns
-------
out : dpnp.ndarray
The indication of the sign of each element of `x`.
The indication of the sign of each element of `x`.

Limitations
-----------
Expand Down Expand Up @@ -1899,7 +1987,7 @@ def subtract(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
The difference of `x1` and `x2`, element-wise.

Limitations
Expand Down Expand Up @@ -1965,7 +2053,7 @@ def sum(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
an array containing the sums. If the sum was computed over the
entire array, a zero-dimensional array is returned. The returned
array has the data type as described in the `dtype` parameter
Expand Down Expand Up @@ -2134,7 +2222,6 @@ def true_divide(*args, **kwargs):
-----
This function works the same as :obj:`dpnp.divide`.


"""

return dpnp.divide(*args, **kwargs)
Expand Down
10 changes: 5 additions & 5 deletions dpnp/dpnp_iface_trigonometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def cos(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
The cosine of each element of `x`.

Limitations
Expand Down Expand Up @@ -738,7 +738,7 @@ def log(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
The natural logarithm of `x`, element-wise.

Limitations
Expand Down Expand Up @@ -982,7 +982,7 @@ def sin(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
The sine of each element of `x`.

Limitations
Expand Down Expand Up @@ -1069,7 +1069,7 @@ def sqrt(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
An array of the same shape as `x`, containing the positive
square-root of each element in `x`. If any element in `x` is
complex, a complex array is returned (and the square-roots of
Expand Down Expand Up @@ -1129,7 +1129,7 @@ def square(

Returns
-------
y : dpnp.ndarray
out : dpnp.ndarray
Element-wise `x * x`, of the same shape and dtype as `x`.

Limitations
Expand Down
Loading