From a51c73d72973e295f8e359d4fc30553756c187d3 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 20 Jan 2026 03:07:05 -0800 Subject: [PATCH 1/7] Add DPNPDeprecatedUnaryFunc wrapper --- dpnp/dpnp_algo/dpnp_elementwise_common.py | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dpnp/dpnp_algo/dpnp_elementwise_common.py b/dpnp/dpnp_algo/dpnp_elementwise_common.py index c404d71dfbc..5f549be2de4 100644 --- a/dpnp/dpnp_algo/dpnp_elementwise_common.py +++ b/dpnp/dpnp_algo/dpnp_elementwise_common.py @@ -60,6 +60,7 @@ "DPNPBinaryFunc", "DPNPBinaryFuncOutKw", "DPNPBinaryTwoOutputsFunc", + "DPNPDeprecatedUnaryFunc", "DPNPImag", "DPNPReal", "DPNPRound", @@ -230,6 +231,29 @@ def _unpack_out_kw(self, out): return out +class DPNPDeprecatedUnaryFunc(DPNPUnaryFunc): + """ + Class that implements a deprecated unary element-wise function. + + Parameters + ---------- + deprecated_msg : {str, None} + Warning message to emit. If None, no warning is issued. + + """ + + def __init__(self, *args, deprecated_msg=None, **kwargs): + super().__init__(*args, **kwargs) + self._deprecated_msg = deprecated_msg + + def __call__(self, *args, **kwargs): + if self._deprecated_msg: + warnings.warn( + self._deprecated_msg, DeprecationWarning, stacklevel=2 + ) + return super().__call__(*args, **kwargs) + + class DPNPUnaryTwoOutputsFunc(UnaryElementwiseFunc): """ Class that implements unary element-wise functions with two output arrays. From 4d624a350cdbe726d3c5273bdde6927ed9b7d054 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 20 Jan 2026 03:26:29 -0800 Subject: [PATCH 2/7] Deprecate dpnp.fix --- dpnp/dpnp_iface_mathematical.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 63aee599d9b..cb76da31a5f 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -66,6 +66,7 @@ DPNPBinaryFunc, DPNPBinaryFuncOutKw, DPNPBinaryTwoOutputsFunc, + DPNPDeprecatedUnaryFunc, DPNPImag, DPNPReal, DPNPRound, @@ -1853,6 +1854,12 @@ def ediff1d(ary, to_end=None, to_begin=None): :obj:`dpnp.floor` : Return the floor of the input, element-wise. :obj:`dpnp.ceil` : Return the ceiling of the input, element-wise. +Warning +------- +This function is deprecated. It is recommended to use +:obj:`dpnp.trunc` instead, as it provides the same functionality of +truncating decimal values to their integer parts. + Examples -------- >>> import dpnp as np @@ -1867,13 +1874,14 @@ def ediff1d(ary, to_end=None, to_begin=None): """ # reuse trunc backend implementation for fix -fix = DPNPUnaryFunc( +fix = DPNPDeprecatedUnaryFunc( "fix", ti._trunc_result_type, ti._trunc, _FIX_DOCSTRING, mkl_fn_to_call="_mkl_trunc_to_call", mkl_impl_fn="_trunc", + deprecated_msg=("dpnp.fix is deprecated in favor of dpnp.trunc"), ) From 678a210edb16d302fb239e6cdc60847f5c608be3 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 20 Jan 2026 04:02:17 -0800 Subject: [PATCH 3/7] Update tests to ignore dpnp.fix DeprecationWarning --- dpnp/tests/test_mathematical.py | 26 +++++++++++++++++-- dpnp/tests/test_sycl_queue.py | 6 ++++- dpnp/tests/test_usm_type.py | 6 ++++- .../cupy/math_tests/test_rounding.py | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/dpnp/tests/test_mathematical.py b/dpnp/tests/test_mathematical.py index 77c65991e9c..de8d61de9a8 100644 --- a/dpnp/tests/test_mathematical.py +++ b/dpnp/tests/test_mathematical.py @@ -2021,7 +2021,18 @@ def test_out_dtype(self, func): @pytest.mark.parametrize("xp", [numpy, dpnp]) @pytest.mark.parametrize( - "func", ["abs", "fix", "round", "add", "frexp", "divmod"] + "func", + [ + "abs", + pytest.param( + "fix", + marks=pytest.mark.filterwarnings("ignore::DeprecationWarning"), + ), + "round", + "add", + "frexp", + "divmod", + ], ) def test_out_wrong_tuple_len(self, xp, func): if func == "round" and xp is numpy: @@ -2536,7 +2547,18 @@ def test_projection(self, dtype): assert dpnp.allclose(result, expected) -@pytest.mark.parametrize("func", ["ceil", "floor", "trunc", "fix"]) +@pytest.mark.parametrize( + "func", + [ + "ceil", + "floor", + "trunc", + pytest.param( + "fix", + marks=pytest.mark.filterwarnings("ignore::DeprecationWarning"), + ), + ], +) class TestRoundingFuncs: @testing.with_requires("numpy>=2.1.0") @pytest.mark.parametrize( diff --git a/dpnp/tests/test_sycl_queue.py b/dpnp/tests/test_sycl_queue.py index 0bd4d6b5333..6dcafa265d5 100644 --- a/dpnp/tests/test_sycl_queue.py +++ b/dpnp/tests/test_sycl_queue.py @@ -264,7 +264,11 @@ def test_meshgrid(device): pytest.param("exp2", [0.0, 1.0, 2.0]), pytest.param("expm1", [1.0e-10, 1.0, 2.0, 4.0, 7.0]), pytest.param("fabs", [-1.2, 1.2]), - pytest.param("fix", [2.1, 2.9, -2.1, -2.9]), + pytest.param( + "fix", + [2.1, 2.9, -2.1, -2.9], + marks=pytest.mark.filterwarnings("ignore::DeprecationWarning"), + ), pytest.param("flatnonzero", [-2, -1, 0, 1, 2]), pytest.param("floor", [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]), pytest.param("gradient", [1.0, 2.0, 4.0, 7.0, 11.0, 16.0]), diff --git a/dpnp/tests/test_usm_type.py b/dpnp/tests/test_usm_type.py index fa4fc62e34c..4fc0f2b958f 100644 --- a/dpnp/tests/test_usm_type.py +++ b/dpnp/tests/test_usm_type.py @@ -572,7 +572,11 @@ def test_meshgrid(usm_type_x, usm_type_y): pytest.param("exp2", [0.0, 1.0, 2.0]), pytest.param("expm1", [1.0e-10, 1.0, 2.0, 4.0, 7.0]), pytest.param("fabs", [-1.2, 1.2]), - pytest.param("fix", [2.1, 2.9, -2.1, -2.9]), + pytest.param( + "fix", + [2.1, 2.9, -2.1, -2.9], + marks=pytest.mark.filterwarnings("ignore::DeprecationWarning"), + ), pytest.param("flatnonzero", [-2, -1, 0, 1, 2]), pytest.param("floor", [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]), pytest.param("gradient", [1, 2, 4, 7, 11, 16]), diff --git a/dpnp/tests/third_party/cupy/math_tests/test_rounding.py b/dpnp/tests/third_party/cupy/math_tests/test_rounding.py index a2ad717f250..10e79715dd1 100644 --- a/dpnp/tests/third_party/cupy/math_tests/test_rounding.py +++ b/dpnp/tests/third_party/cupy/math_tests/test_rounding.py @@ -66,6 +66,7 @@ def test_trunc(self): self.check_unary("trunc") self.check_unary_complex_unsupported("trunc") + @pytest.mark.filterwarnings("ignore::DeprecationWarning") @testing.with_requires("numpy>=2.1") def test_fix(self): self.check_unary("fix") From 3b9f076af616ac20499eb78d18cf428507dbad13 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 20 Jan 2026 04:16:26 -0800 Subject: [PATCH 4/7] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c9d2c97376..1f20e0b2bea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * `dpnp.asfarray` is deprecated. Use `dpnp.asarray` with an appropriate dtype instead [#2650](https://github.com/IntelPython/dpnp/pull/2650) * Passing the output array ``out`` positionally to `dpnp.minimum` and `dpnp.maximum` is deprecated. Pass the output with the keyword form, e.g. ``dpnp.minimum(a, b, out=c)`` [#2659](https://github.com/IntelPython/dpnp/pull/2659) * `dpnp.ndarray.T` property is deprecated for not two-dimensional array to be compatible with the Python array API standard. To achieve a similar behavior when ``a.ndim != 2``, either ``a.transpose()``, or ``a.mT`` (swaps the last two axes only), or ``dpnp.permute_dims(a, range(a.ndim)[::-1])`` can be used [#2681](https://github.com/IntelPython/dpnp/pull/2681) +* `dpnp.fix` is deprecated. Use `dpnp.trunc` instead [#2730](https://github.com/IntelPython/dpnp/pull/2730) ### Removed From 1c552f63d6a3ebc1551dde63c5f25cd63e43ac6c Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 20 Jan 2026 05:33:02 -0800 Subject: [PATCH 5/7] Apply remarks --- CHANGELOG.md | 2 +- dpnp/dpnp_algo/dpnp_elementwise_common.py | 4 +++- dpnp/dpnp_iface_mathematical.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f20e0b2bea..5cffd986205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum * `dpnp.asfarray` is deprecated. Use `dpnp.asarray` with an appropriate dtype instead [#2650](https://github.com/IntelPython/dpnp/pull/2650) * Passing the output array ``out`` positionally to `dpnp.minimum` and `dpnp.maximum` is deprecated. Pass the output with the keyword form, e.g. ``dpnp.minimum(a, b, out=c)`` [#2659](https://github.com/IntelPython/dpnp/pull/2659) * `dpnp.ndarray.T` property is deprecated for not two-dimensional array to be compatible with the Python array API standard. To achieve a similar behavior when ``a.ndim != 2``, either ``a.transpose()``, or ``a.mT`` (swaps the last two axes only), or ``dpnp.permute_dims(a, range(a.ndim)[::-1])`` can be used [#2681](https://github.com/IntelPython/dpnp/pull/2681) -* `dpnp.fix` is deprecated. Use `dpnp.trunc` instead [#2730](https://github.com/IntelPython/dpnp/pull/2730) +* `dpnp.fix` is deprecated. Use `dpnp.trunc` instead, which provides identical functionality [#2730](https://github.com/IntelPython/dpnp/pull/2730) ### Removed diff --git a/dpnp/dpnp_algo/dpnp_elementwise_common.py b/dpnp/dpnp_algo/dpnp_elementwise_common.py index 5f549be2de4..b069eb7c6ed 100644 --- a/dpnp/dpnp_algo/dpnp_elementwise_common.py +++ b/dpnp/dpnp_algo/dpnp_elementwise_common.py @@ -237,9 +237,11 @@ class DPNPDeprecatedUnaryFunc(DPNPUnaryFunc): Parameters ---------- - deprecated_msg : {str, None} + deprecated_msg : {str, None}, optional Warning message to emit. If None, no warning is issued. + Default: ``None``. + """ def __init__(self, *args, deprecated_msg=None, **kwargs): diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index cb76da31a5f..3633a2eebdf 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -1881,7 +1881,7 @@ def ediff1d(ary, to_end=None, to_begin=None): _FIX_DOCSTRING, mkl_fn_to_call="_mkl_trunc_to_call", mkl_impl_fn="_trunc", - deprecated_msg=("dpnp.fix is deprecated in favor of dpnp.trunc"), + deprecated_msg="dpnp.fix is deprecated in favor of dpnp.trunc", ) From 01ffd4a9421128a810943cca20a50b0aa7e00dfc Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 21 Jan 2026 05:02:05 -0800 Subject: [PATCH 6/7] Add wraps() for correct signature in docs --- dpnp/dpnp_algo/dpnp_elementwise_common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dpnp/dpnp_algo/dpnp_elementwise_common.py b/dpnp/dpnp_algo/dpnp_elementwise_common.py index b069eb7c6ed..57bf50422fa 100644 --- a/dpnp/dpnp_algo/dpnp_elementwise_common.py +++ b/dpnp/dpnp_algo/dpnp_elementwise_common.py @@ -248,6 +248,7 @@ def __init__(self, *args, deprecated_msg=None, **kwargs): super().__init__(*args, **kwargs) self._deprecated_msg = deprecated_msg + @wraps(DPNPUnaryFunc.__call__) def __call__(self, *args, **kwargs): if self._deprecated_msg: warnings.warn( From 59acfe54475bf7129ee3d694e86e3ed955ffb03c Mon Sep 17 00:00:00 2001 From: vlad-perevezentsev Date: Wed, 21 Jan 2026 15:38:47 +0100 Subject: [PATCH 7/7] apply a small nit Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com> --- dpnp/dpnp_iface_mathematical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 3633a2eebdf..3e6a4b0ed12 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -1857,7 +1857,7 @@ def ediff1d(ary, to_end=None, to_begin=None): Warning ------- This function is deprecated. It is recommended to use -:obj:`dpnp.trunc` instead, as it provides the same functionality of +:func:`dpnp.trunc` instead, as it provides the same functionality of truncating decimal values to their integer parts. Examples