Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vtavana committed Oct 9, 2023
1 parent 988f2fc commit a3fa354
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 47 deletions.
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/vm/types_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ template <typename T>
struct AbsOutputType
{
using value_type = typename std::disjunction<
// TODO: Add complex type here, currently adding them here generates a
// compile time error due to probably a bug in mkl
dpctl_td_ns::TypeMapResultEntry<T, double>,
dpctl_td_ns::TypeMapResultEntry<T, float>,
dpctl_td_ns::DefaultResultEntry<void>>::result_type;
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/vm/vm_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ PYBIND11_MODULE(_vm_impl, m)
};
m.def("_abs", abs_pyapi,
"Call `abs` function from OneMKL VM library to compute "
"the absolute of vector elements",
"the absolute value of vector elements",
py::arg("sycl_queue"), py::arg("src"), py::arg("dst"),
py::arg("depends") = py::list());

Expand Down
62 changes: 16 additions & 46 deletions dpnp/dpnp_iface_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,46 +127,6 @@
]


def abs(
x,
/,
out=None,
*,
order="K",
where=True,
dtype=None,
subok=True,
**kwargs,
):
"""
Calculate the absolute value element-wise.
For full documentation refer to :obj:`numpy.absolute`.
Notes
-----
:obj:`dpnp.abs` is a shorthand for :obj:`dpnp.absolute`.
Examples
--------
>>> import dpnp as np
>>> a = np.array([-1.2, 1.2])
>>> np.abs(a)
array([1.2, 1.2])
"""

return dpnp.absolute(
x,
out,
order="K",
where=where,
dtype=dtype,
subok=subok,
**kwargs,
)


def absolute(
x,
/,
Expand Down Expand Up @@ -198,16 +158,23 @@ def absolute(
See Also
--------
:obj:`dpnp.abs` : is a shorthand for this function..
:obj:`dpnp.fabs` : Calculate the absolute value element-wise excluding complex types.
Notes
-----
``dpnp.abs`` is a shorthand for this function.
Examples
--------
>>> import dpnp as dp
>>> a = dp.array([-1.2, 1.2])
>>> dp.absolute(a)
>>> import dpnp as np
>>> a = np.array([-1.2, 1.2])
>>> np.absolute(a)
array([1.2, 1.2])
>>> a = np.array(1.2 + 1j)
>>> np.absolute(a)
array(1.5620499351813308)
"""

return check_nd_call_func(
Expand All @@ -223,6 +190,9 @@ def absolute(
)


abs = absolute


def add(
x1,
x2,
Expand Down Expand Up @@ -835,7 +805,7 @@ def fabs(x1, **kwargs):
See Also
--------
:obj:`dpnp.abs` : Calculate the absolute value element-wise.
:obj:`dpnp.absolute` : Calculate the absolute value element-wise.
Examples
--------
Expand Down Expand Up @@ -2152,7 +2122,7 @@ def proj(
See Also
--------
:obj:`dpnp.abs` : Returns the magnitude of a complex number, element-wise.
:obj:`dpnp.absolute` : Returns the magnitude of a complex number, element-wise.
:obj:`dpnp.conj` : Return the complex conjugate, element-wise.
Examples
Expand Down

0 comments on commit a3fa354

Please sign in to comment.