Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -33,6 +33,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
55 changes: 53 additions & 2 deletions dpnp/dpnp_iface_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

import builtins
import warnings
from functools import wraps

import dpctl.tensor as dpt
import dpctl.tensor._tensor_elementwise_impl as ti
Expand Down Expand Up @@ -3202,6 +3203,14 @@ def interp(x, xp, fp, left=None, right=None, period=None):

Default: ``"K"``.

Warning
-------
Passing the output array ``out`` positionally is deprecated.
For example, ``dpnp.maximum(a, b, c)`` will emit a ``DeprecationWarning``.

Always pass the output with the keyword form, e.g.
``dpnp.maximum(a, b, out=c)``.

Returns
-------
out : dpnp.ndarray
Expand Down Expand Up @@ -3255,14 +3264,31 @@ def interp(x, xp, fp, left=None, right=None, period=None):

"""

maximum = DPNPBinaryFunc(
_maximum_impl = DPNPBinaryFunc(
"maximum",
ti._maximum_result_type,
ti._maximum,
_MAXIMUM_DOCSTRING,
)


@wraps(_maximum_impl)
def maximum(*args, **kwargs):
"""
Wrapper around `_maximum_impl` that emits a DeprecationWarning
when `out` is passed positionally.

"""
if len(args) >= 3 and "out" not in kwargs:
warnings.warn(
"Positional `out` argument to `dpnp.maximum` is deprecated. "
"Please use the keyword form, e.g. `dpnp.maximum(a, b, out=c)`.",
DeprecationWarning,
stacklevel=2,
)
return _maximum_impl(*args, **kwargs)


_MINIMUM_DOCSTRING = """
Computes the minimum value for each element :math:`x1_i` of the input array `x1`
relative to the respective element :math:`x2_i` of the input array `x2`.
Expand Down Expand Up @@ -3297,6 +3323,14 @@ 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 the output array ``out`` positionally is deprecated.
For example, ``dpnp.minimum(a, b, c)`` will emit a ``DeprecationWarning``.

Always pass the output with the keyword form, e.g.
``dpnp.minimum(a, b, out=c)``.

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

minimum = DPNPBinaryFunc(
_minimum_impl = DPNPBinaryFunc(
"minimum",
ti._minimum_result_type,
ti._minimum,
_MINIMUM_DOCSTRING,
)


@wraps(_minimum_impl)
def minimum(*args, **kwargs):
"""
Wrapper around `_minimum_impl` that emits a DeprecationWarning
when `out` is passed positionally.

"""
if len(args) >= 3 and "out" not in kwargs:
warnings.warn(
"Positional `out` argument to `dpnp.minimum` is deprecated. "
"Please use the keyword form, e.g. `dpnp.minimum(a, b, out=c)`.",
DeprecationWarning,
stacklevel=2,
)
return _minimum_impl(*args, **kwargs)


def modf(x1, **kwargs):
"""
Return the fractional and integral parts of an array, element-wise.
Expand Down
10 changes: 10 additions & 0 deletions dpnp/tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2910,3 +2910,13 @@ def test_elemenwise_outer_scalar():
expected = dpnp.add.outer(x, y)
result = dpnp.add.outer(x, s)
assert dpnp.allclose(result, expected)


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

with pytest.warns(DeprecationWarning, match="deprecated"):
_ = getattr(dpnp, func)(a, b, out)
Loading