From 0f9fb883c6cb42547f1876c4f3372ffb185afa9c Mon Sep 17 00:00:00 2001 From: Vahid Tavanashad Date: Mon, 31 Mar 2025 08:30:42 -0700 Subject: [PATCH 1/3] remove w/a related to dpctl-issue-2030 --- dpnp/dpnp_iface_mathematical.py | 2 +- dpnp/tests/test_mathematical.py | 16 +--------------- dpnp/tests/test_umath.py | 2 -- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 8d35d62b1a9..9a1973b8ae5 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -1736,7 +1736,7 @@ def ediff1d(ary, to_end=None, to_begin=None): Parameters ---------- x : {dpnp.ndarray, usm_ndarray} - Input array, expected to have a real-valued data type. + Input array, expected to have a boolean or real-valued data type. out : {None, dpnp.ndarray, usm_ndarray}, optional Output array to populate. Array must have the correct shape and the expected data type. diff --git a/dpnp/tests/test_mathematical.py b/dpnp/tests/test_mathematical.py index b66b65dc1c4..61247ea0893 100644 --- a/dpnp/tests/test_mathematical.py +++ b/dpnp/tests/test_mathematical.py @@ -2240,20 +2240,11 @@ def test_out(self, func, dt_in, dt_out): if dt_in != dt_out: if numpy.can_cast(dt_in, dt_out, casting="same_kind"): # NumPy allows "same_kind" casting, dpnp does not - if func != "fix" and dt_in == dpnp.bool and dt_out == dpnp.int8: - # TODO: get rid of w/a when dpctl#2030 is fixed - pass - else: - assert_raises(ValueError, getattr(dpnp, func), ia, out=iout) + assert_raises(ValueError, getattr(dpnp, func), ia, out=iout) else: assert_raises(ValueError, getattr(dpnp, func), ia, out=iout) assert_raises(TypeError, getattr(numpy, func), a, out=out) else: - if func != "fix" and dt_in == dpnp.bool: - # TODO: get rid of w/a when dpctl#2030 is fixed - out = out.astype(numpy.int8) - iout = iout.astype(dpnp.int8) - expected = getattr(numpy, func)(a, out=out) result = getattr(dpnp, func)(ia, out=iout) assert result is iout @@ -2279,11 +2270,6 @@ def test_out_usm_ndarray(self, func, dt): out = numpy.empty(a.shape, dtype=dt) ia, usm_out = dpnp.array(a), dpt.asarray(out) - if func != "fix" and dt == dpnp.bool: - # TODO: get rid of w/a when dpctl#2030 is fixed - out = out.astype(numpy.int8) - usm_out = dpt.asarray(usm_out, dtype=dpnp.int8) - expected = getattr(numpy, func)(a, out=out) result = getattr(dpnp, func)(ia, out=usm_out) assert result.get_array() is usm_out diff --git a/dpnp/tests/test_umath.py b/dpnp/tests/test_umath.py index 5cc7d5f839b..53a5d8d37bc 100644 --- a/dpnp/tests/test_umath.py +++ b/dpnp/tests/test_umath.py @@ -108,8 +108,6 @@ def test_umaths(test_cases): and is_gpu_device() ): pytest.skip("dpctl-1652") - elif umath in ["ceil", "floor", "trunc"] and args[0].dtype == dpnp.bool: - pytest.skip("dpctl-2030") elif ( umath == "tan" and dpnp.issubdtype(args[0].dtype, dpnp.complexfloating) From 4a4982130c6fa0b5c75e876822a70d0d371a6041 Mon Sep 17 00:00:00 2001 From: Vahid Tavanashad Date: Wed, 2 Apr 2025 05:10:09 -0700 Subject: [PATCH 2/3] update docstring for floor, ceil, trunc --- dpnp/dpnp_iface_mathematical.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 29497b3b73b..b817d439c93 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -91,6 +91,7 @@ "clip", "conj", "conjugate", + "convolve", "copysign", "cross", "cumprod", @@ -611,7 +612,7 @@ def around(x, /, decimals=0, out=None): Parameters ---------- x : {dpnp.ndarray, usm_ndarray} - Input array, expected to have a real-valued data type. + Input array, expected to have a boolean or real-valued data type. out : {None, dpnp.ndarray, usm_ndarray}, optional Output array to populate. Array must have the correct shape and the expected data type. @@ -791,6 +792,24 @@ def clip(a, /, min=None, max=None, *, out=None, order="K", **kwargs): conj = conjugate + +def convolve(a, v, mode="full"): + """ + Returns the discrete, linear convolution of two one-dimensional sequences. + + For full documentation refer to :obj:`numpy.convolve`. + + Examples + -------- + >>> ca = dpnp.convolve([1, 2, 3], [0, 1, 0.5]) + >>> print(ca) + [0. , 1. , 2.5, 4. , 1.5] + + """ + + return call_origin(numpy.convolve, a=a, v=v, mode=mode) + + _COPYSIGN_DOCSTRING = """ Composes a floating-point value with the magnitude of `x1_i` and the sign of `x2_i` for each element of input arrays `x1` and `x2`. @@ -1878,7 +1897,7 @@ def ediff1d(ary, to_end=None, to_begin=None): Parameters ---------- x : {dpnp.ndarray, usm_ndarray} - Input array, expected to have a real-valued data type. + Input array, expected to have a boolean or real-valued data type. out : {None, dpnp.ndarray, usm_ndarray}, optional Output array to populate. Array must have the correct shape and the expected data type. @@ -4551,7 +4570,7 @@ def trapezoid(y, x=None, dx=1.0, axis=-1): Parameters ---------- x : {dpnp.ndarray, usm_ndarray} - Input array, expected to have a real-valued data type. + Input array, expected to have a boolean or real-valued data type. out : {None, dpnp.ndarray, usm_ndarray}, optional Output array to populate. Array must have the correct shape and the expected data type. From 026c39c6517162446376b425b39ee93d031aea12 Mon Sep 17 00:00:00 2001 From: Vahid Tavanashad Date: Wed, 2 Apr 2025 05:12:28 -0700 Subject: [PATCH 3/3] remove leftovers from merge process --- dpnp/dpnp_iface_mathematical.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index b817d439c93..9c9a8049a14 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -91,7 +91,6 @@ "clip", "conj", "conjugate", - "convolve", "copysign", "cross", "cumprod", @@ -793,23 +792,6 @@ def clip(a, /, min=None, max=None, *, out=None, order="K", **kwargs): conj = conjugate -def convolve(a, v, mode="full"): - """ - Returns the discrete, linear convolution of two one-dimensional sequences. - - For full documentation refer to :obj:`numpy.convolve`. - - Examples - -------- - >>> ca = dpnp.convolve([1, 2, 3], [0, 1, 0.5]) - >>> print(ca) - [0. , 1. , 2.5, 4. , 1.5] - - """ - - return call_origin(numpy.convolve, a=a, v=v, mode=mode) - - _COPYSIGN_DOCSTRING = """ Composes a floating-point value with the magnitude of `x1_i` and the sign of `x2_i` for each element of input arrays `x1` and `x2`.