Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f519e26
Deprecate positional out argument in dpnp.minimum
vlad-perevezentsev Nov 10, 2025
83ace79
Deprecate positional out argument in dpnp.maximum
vlad-perevezentsev Nov 10, 2025
10ce7b6
Add Warning section to maximum/minimum docs
vlad-perevezentsev Nov 10, 2025
74a0f02
Add warning test
vlad-perevezentsev Nov 10, 2025
c4e350d
Update changelog
vlad-perevezentsev Nov 10, 2025
c0d0e49
Merge master into deprecated_out_arg
vlad-perevezentsev Nov 10, 2025
1cd390b
Update changelog
vlad-perevezentsev Nov 10, 2025
0090fb0
Update Warning section to maximum/minimum docs
vlad-perevezentsev Nov 11, 2025
00fbb7d
Update DeprecationWarning text
vlad-perevezentsev Nov 11, 2025
a893287
Add DPNPBinaryFuncOutKw class to handle positional out deprecation
vlad-perevezentsev Nov 11, 2025
29494e1
Update test_minimum_maximum_out_deprecated
vlad-perevezentsev Nov 11, 2025
e917db4
Merge master into deprecated_out_arg
vlad-perevezentsev Nov 11, 2025
81b1ded
Use wraps to restore proper signature in DPNPBinaryFuncOutKw
vlad-perevezentsev Nov 11, 2025
75f6a27
Merge master into deprecated_out_arg
vlad-perevezentsev Nov 11, 2025
a0e4d77
Avoid DeprecationWarning from dpnp.asfarray in tests
vlad-perevezentsev Nov 11, 2025
7a754f7
Merge master into deprecated_out_arg
vlad-perevezentsev Nov 11, 2025
19f0889
Ignore DeprecationWarning in TestBoundFuncs::test_invalid_out
vlad-perevezentsev Nov 11, 2025
f0c0206
Merge master into deprecated_out_arg
vlad-perevezentsev Nov 12, 2025
7cf3628
Update test_invalid_out_type to avoid DeprecationWarning
vlad-perevezentsev Nov 12, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
### Deprecated

* `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)

### Removed

Expand Down
9 changes: 8 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from dpnp.dpnp_algo.dpnp_elementwise_common import (
DPNPBinaryFunc,
DPNPBinaryFuncOutKw,
DPNPUnaryFunc,
DPNPUnaryTwoOutputsFunc,
)
Expand Down Expand Up @@ -210,7 +211,13 @@
# -- Options for todo extension ----------------------------------------------
def _can_document_member(member, *args, **kwargs):
if isinstance(
member, (DPNPBinaryFunc, DPNPUnaryFunc, DPNPUnaryTwoOutputsFunc)
member,
(
DPNPBinaryFunc,
DPNPBinaryFuncOutKw,
DPNPUnaryFunc,
DPNPUnaryTwoOutputsFunc,
),
):
return True
return orig(member, *args, **kwargs)
Expand Down
20 changes: 20 additions & 0 deletions dpnp/dpnp_algo/dpnp_elementwise_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
# THE POSSIBILITY OF SUCH DAMAGE.
# *****************************************************************************

import warnings
from functools import wraps

import dpctl.tensor as dpt
import dpctl.tensor._copy_utils as dtc
import dpctl.tensor._tensor_impl as dti
Expand All @@ -48,6 +51,7 @@
"DPNPI0",
"DPNPAngle",
"DPNPBinaryFunc",
"DPNPBinaryFuncOutKw",
"DPNPFix",
"DPNPImag",
"DPNPReal",
Expand Down Expand Up @@ -775,6 +779,22 @@ def outer(
)


class DPNPBinaryFuncOutKw(DPNPBinaryFunc):
"""DPNPBinaryFunc that deprecates positional `out` argument."""

@wraps(DPNPBinaryFunc.__call__)
def __call__(self, *args, **kwargs):
if len(args) > self.nin:
warnings.warn(
"Passing more than 2 positional arguments is deprecated. "
"If you meant to use the third argument as an output, "
"use the `out` keyword argument instead.",
DeprecationWarning,
stacklevel=2,
)
return super().__call__(*args, **kwargs)


class DPNPAngle(DPNPUnaryFunc):
"""Class that implements dpnp.angle unary element-wise functions."""

Expand Down
25 changes: 23 additions & 2 deletions dpnp/dpnp_iface_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
DPNPI0,
DPNPAngle,
DPNPBinaryFunc,
DPNPBinaryFuncOutKw,
DPNPFix,
DPNPImag,
DPNPReal,
Expand Down Expand Up @@ -3244,6 +3245,16 @@ def interp(x, xp, fp, left=None, right=None, period=None):

Default: ``"K"``.

Warning
-------
Passing more than 2 positional arguments is deprecated.
If you meant to use the third argument as an output,
use the `out` keyword argument instead.

For example, ``dpnp.maximum(a, b, c)`` will emit a ``DeprecationWarning``.
Always pass the output array as the keyword argument instead, that is
``dpnp.maximum(a, b, out=c)``.

Returns
-------
out : dpnp.ndarray
Expand Down Expand Up @@ -3297,7 +3308,7 @@ def interp(x, xp, fp, left=None, right=None, period=None):

"""

maximum = DPNPBinaryFunc(
maximum = DPNPBinaryFuncOutKw(
"maximum",
ti._maximum_result_type,
ti._maximum,
Expand Down Expand Up @@ -3341,6 +3352,16 @@ def interp(x, xp, fp, left=None, right=None, period=None):
An array containing the element-wise minima. The data type of
the returned array is determined by the Type Promotion Rules.

Warning
-------
Passing more than 2 positional arguments is deprecated.
If you meant to use the third argument as an output,
use the `out` keyword argument instead.

For example, ``dpnp.minimum(a, b, c)`` will emit a ``DeprecationWarning``.
Always pass the output array as the keyword argument instead, that is
``dpnp.minimum(a, b, out=c)``.

Limitations
-----------
Parameters `where` and `subok` are supported with their default values.
Expand Down Expand Up @@ -3387,7 +3408,7 @@ def interp(x, xp, fp, left=None, right=None, period=None):
array(-inf)
"""

minimum = DPNPBinaryFunc(
minimum = DPNPBinaryFuncOutKw(
"minimum",
ti._minimum_result_type,
ti._minimum,
Expand Down
2 changes: 1 addition & 1 deletion dpnp/tests/test_binary_ufuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_invalid_shape(self, func, shape):
)
def test_invalid_out_type(self, func, xp, out):
a = xp.arange(10)
assert_raises(TypeError, getattr(xp, func), a, 2, out)
assert_raises(TypeError, getattr(xp, func), a, 2, out=out)


class TestDivide:
Expand Down
12 changes: 12 additions & 0 deletions dpnp/tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2795,3 +2795,15 @@ def test_elemenwise_outer_scalar():
expected = dpnp.add.outer(x, y)
result = dpnp.add.outer(x, s)
assert dpnp.allclose(result, expected)


@testing.with_requires("numpy>=2.4")
@pytest.mark.parametrize("xp", [dpnp, numpy])
@pytest.mark.parametrize("func", ["minimum", "maximum"])
def test_minimum_maximum_out_deprecated(xp, func):
a = xp.array([1, 3, 2])
b = xp.array([2, 2, 2])
out = xp.empty_like(a)

with pytest.warns(DeprecationWarning, match="deprecated"):
_ = getattr(xp, func)(a, b, out)
5 changes: 4 additions & 1 deletion dpnp/tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,10 @@ def test_invalid_stream(self, stream):
"asarray_chkfinite",
"asanyarray",
"ascontiguousarray",
"asfarray",
pytest.param(
"asfarray",
marks=pytest.mark.filterwarnings("ignore::DeprecationWarning"),
),
"asfortranarray",
],
)
Expand Down
5 changes: 4 additions & 1 deletion dpnp/tests/test_usm_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ def test_copy_operation(usm_type):
"asarray_chkfinite",
"asanyarray",
"ascontiguousarray",
"asfarray",
pytest.param(
"asfarray",
marks=pytest.mark.filterwarnings("ignore::DeprecationWarning"),
),
"asfortranarray",
],
)
Expand Down
Loading