From a3fa3544b946ef9d3ed38df0127e2ec788d879e9 Mon Sep 17 00:00:00 2001 From: Vahid Tavanashad Date: Mon, 9 Oct 2023 10:59:40 -0500 Subject: [PATCH] address comments --- dpnp/backend/extensions/vm/types_matrix.hpp | 2 + dpnp/backend/extensions/vm/vm_py.cpp | 2 +- dpnp/dpnp_iface_mathematical.py | 62 ++++++--------------- 3 files changed, 19 insertions(+), 47 deletions(-) diff --git a/dpnp/backend/extensions/vm/types_matrix.hpp b/dpnp/backend/extensions/vm/types_matrix.hpp index 7588edb09c6..78b1c8550e9 100644 --- a/dpnp/backend/extensions/vm/types_matrix.hpp +++ b/dpnp/backend/extensions/vm/types_matrix.hpp @@ -53,6 +53,8 @@ template 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, dpctl_td_ns::TypeMapResultEntry, dpctl_td_ns::DefaultResultEntry>::result_type; diff --git a/dpnp/backend/extensions/vm/vm_py.cpp b/dpnp/backend/extensions/vm/vm_py.cpp index c651e4bac7b..0b31901569a 100644 --- a/dpnp/backend/extensions/vm/vm_py.cpp +++ b/dpnp/backend/extensions/vm/vm_py.cpp @@ -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()); diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 887a69adf89..650c0478e17 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -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, /, @@ -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( @@ -223,6 +190,9 @@ def absolute( ) +abs = absolute + + def add( x1, x2, @@ -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 -------- @@ -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