Skip to content

Commit bcb399f

Browse files
Merge master into refactor_public_api_exports
2 parents a9c5398 + 0c92fce commit bcb399f

21 files changed

+137
-83
lines changed

.github/workflows/openssf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ jobs:
7272

7373
# Upload the results to GitHub's code scanning dashboard.
7474
- name: "Upload to code-scanning"
75-
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
75+
uses: github/codeql-action/upload-sarif@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
7676
with:
7777
sarif_file: results.sarif

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ repos:
6464
additional_dependencies:
6565
- tomli
6666
- repo: https://github.com/psf/black
67-
rev: 25.9.0
67+
rev: 25.11.0
6868
hooks:
6969
- id: black
7070
exclude: "dpnp/_version.py"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
2323
* Added implementation of `dpnp.ndarray.tofile` method [#2635](https://github.com/IntelPython/dpnp/pull/2635)
2424
* Extended `pre-commit` configuration with `pyupgrade`, `actionlint`, and `gersemi` hooks [#2658](https://github.com/IntelPython/dpnp/pull/2658)
2525
* Added implementation of `dpnp.ndarray.tobytes` method [#2656](https://github.com/IntelPython/dpnp/pull/2656)
26+
* Added implementation of `dpnp.ndarray.__format__` method [#2662](https://github.com/IntelPython/dpnp/pull/2662)
2627

2728
### Changed
2829

@@ -34,10 +35,12 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
3435
* Redesigned `dpnp.modf` function to be a part of `ufunc` and `vm` pybind11 extensions [#2654](https://github.com/IntelPython/dpnp/pull/2654)
3536
* Refactored `dpnp.fft` and `dpnp.random` submodules by removing wildcard imports and defining explicit public exports [#2649](https://github.com/IntelPython/dpnp/pull/2649)
3637
* Added support for the `out` keyword to accept a tuple, bringing ufunc signatures into alignment with those in NumPy [#2664](https://github.com/IntelPython/dpnp/pull/2664)
38+
* Unified public API definitions in `dpnp.linalg` and `dpnp.scipy` submodules [#2663](https://github.com/IntelPython/dpnp/pull/2663)
3739

3840
### Deprecated
3941

4042
* `dpnp.asfarray` is deprecated. Use `dpnp.asarray` with an appropriate dtype instead [#2650](https://github.com/IntelPython/dpnp/pull/2650)
43+
* 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)
4144

4245
### Removed
4346

doc/conf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from dpnp.dpnp_algo.dpnp_elementwise_common import (
1414
DPNPBinaryFunc,
15+
DPNPBinaryFuncOutKw,
1516
DPNPUnaryFunc,
1617
DPNPUnaryTwoOutputsFunc,
1718
)
@@ -210,7 +211,13 @@
210211
# -- Options for todo extension ----------------------------------------------
211212
def _can_document_member(member, *args, **kwargs):
212213
if isinstance(
213-
member, (DPNPBinaryFunc, DPNPUnaryFunc, DPNPUnaryTwoOutputsFunc)
214+
member,
215+
(
216+
DPNPBinaryFunc,
217+
DPNPBinaryFuncOutKw,
218+
DPNPUnaryFunc,
219+
DPNPUnaryTwoOutputsFunc,
220+
),
214221
):
215222
return True
216223
return orig(member, *args, **kwargs)

doc/reference/ndarray.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,4 @@ String representations:
449449

450450
ndarray.__str__
451451
ndarray.__repr__
452+
ndarray.__format__

dpnp/dpnp_algo/dpnp_elementwise_common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
# THE POSSIBILITY OF SUCH DAMAGE.
2727
# *****************************************************************************
2828

29+
import warnings
30+
from functools import wraps
31+
2932
import dpctl.tensor as dpt
3033
import dpctl.tensor._copy_utils as dtc
3134
import dpctl.tensor._tensor_impl as dti
@@ -48,6 +51,7 @@
4851
"DPNPI0",
4952
"DPNPAngle",
5053
"DPNPBinaryFunc",
54+
"DPNPBinaryFuncOutKw",
5155
"DPNPFix",
5256
"DPNPImag",
5357
"DPNPReal",
@@ -775,6 +779,22 @@ def outer(
775779
)
776780

777781

782+
class DPNPBinaryFuncOutKw(DPNPBinaryFunc):
783+
"""DPNPBinaryFunc that deprecates positional `out` argument."""
784+
785+
@wraps(DPNPBinaryFunc.__call__)
786+
def __call__(self, *args, **kwargs):
787+
if len(args) > self.nin:
788+
warnings.warn(
789+
"Passing more than 2 positional arguments is deprecated. "
790+
"If you meant to use the third argument as an output, "
791+
"use the `out` keyword argument instead.",
792+
DeprecationWarning,
793+
stacklevel=2,
794+
)
795+
return super().__call__(*args, **kwargs)
796+
797+
778798
class DPNPAngle(DPNPUnaryFunc):
779799
"""Class that implements dpnp.angle unary element-wise functions."""
780800

dpnp/dpnp_array.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ def __floordiv__(self, other, /):
302302
r"""Return :math:`\text{self // value}`."""
303303
return dpnp.floor_divide(self, other)
304304

305-
# '__format__',
305+
def __format__(self, format_spec):
306+
r"""Return :math:`\text{format(self, format_spec)}`."""
307+
return format(self.asnumpy(), format_spec)
306308

307309
def __ge__(self, other, /):
308310
r"""Return :math:`\text{self >= value}`."""

dpnp/dpnp_iface_mathematical.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
DPNPI0,
6565
DPNPAngle,
6666
DPNPBinaryFunc,
67+
DPNPBinaryFuncOutKw,
6768
DPNPFix,
6869
DPNPImag,
6970
DPNPReal,
@@ -3178,6 +3179,16 @@ def interp(x, xp, fp, left=None, right=None, period=None):
31783179
31793180
Default: ``"K"``.
31803181
3182+
Warning
3183+
-------
3184+
Passing more than 2 positional arguments is deprecated.
3185+
If you meant to use the third argument as an output,
3186+
use the `out` keyword argument instead.
3187+
3188+
For example, ``dpnp.maximum(a, b, c)`` will emit a ``DeprecationWarning``.
3189+
Always pass the output array as the keyword argument instead, that is
3190+
``dpnp.maximum(a, b, out=c)``.
3191+
31813192
Returns
31823193
-------
31833194
out : dpnp.ndarray
@@ -3231,7 +3242,7 @@ def interp(x, xp, fp, left=None, right=None, period=None):
32313242
32323243
"""
32333244

3234-
maximum = DPNPBinaryFunc(
3245+
maximum = DPNPBinaryFuncOutKw(
32353246
"maximum",
32363247
ti._maximum_result_type,
32373248
ti._maximum,
@@ -3275,6 +3286,16 @@ def interp(x, xp, fp, left=None, right=None, period=None):
32753286
An array containing the element-wise minima. The data type of
32763287
the returned array is determined by the Type Promotion Rules.
32773288
3289+
Warning
3290+
-------
3291+
Passing more than 2 positional arguments is deprecated.
3292+
If you meant to use the third argument as an output,
3293+
use the `out` keyword argument instead.
3294+
3295+
For example, ``dpnp.minimum(a, b, c)`` will emit a ``DeprecationWarning``.
3296+
Always pass the output array as the keyword argument instead, that is
3297+
``dpnp.minimum(a, b, out=c)``.
3298+
32783299
Limitations
32793300
-----------
32803301
Parameters `where` and `subok` are supported with their default values.
@@ -3321,7 +3342,7 @@ def interp(x, xp, fp, left=None, right=None, period=None):
33213342
array(-inf)
33223343
"""
33233344

3324-
minimum = DPNPBinaryFunc(
3345+
minimum = DPNPBinaryFuncOutKw(
33253346
"minimum",
33263347
ti._minimum_result_type,
33273348
ti._minimum,

dpnp/linalg/__init__.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838

3939
from .dpnp_iface_linalg import (
4040
LinAlgError,
41-
)
42-
from .dpnp_iface_linalg import __all__ as __all__linalg
43-
from .dpnp_iface_linalg import (
4441
cholesky,
4542
cond,
4643
cross,
@@ -74,4 +71,37 @@
7471
vector_norm,
7572
)
7673

77-
__all__ = __all__linalg
74+
__all__ = [
75+
"LinAlgError",
76+
"cholesky",
77+
"cond",
78+
"cross",
79+
"det",
80+
"diagonal",
81+
"eig",
82+
"eigh",
83+
"eigvals",
84+
"eigvalsh",
85+
"inv",
86+
"lstsq",
87+
"matmul",
88+
"matrix_norm",
89+
"matrix_power",
90+
"matrix_rank",
91+
"matrix_transpose",
92+
"multi_dot",
93+
"norm",
94+
"outer",
95+
"pinv",
96+
"qr",
97+
"solve",
98+
"svd",
99+
"svdvals",
100+
"slogdet",
101+
"tensordot",
102+
"tensorinv",
103+
"tensorsolve",
104+
"trace",
105+
"vecdot",
106+
"vector_norm",
107+
]

dpnp/linalg/dpnp_iface_linalg.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -71,41 +71,6 @@
7171
dpnp_svd,
7272
)
7373

74-
__all__ = [
75-
"LinAlgError",
76-
"cholesky",
77-
"cond",
78-
"cross",
79-
"det",
80-
"diagonal",
81-
"eig",
82-
"eigh",
83-
"eigvals",
84-
"eigvalsh",
85-
"inv",
86-
"lstsq",
87-
"matmul",
88-
"matrix_norm",
89-
"matrix_power",
90-
"matrix_rank",
91-
"matrix_transpose",
92-
"multi_dot",
93-
"norm",
94-
"outer",
95-
"pinv",
96-
"qr",
97-
"solve",
98-
"svd",
99-
"svdvals",
100-
"slogdet",
101-
"tensordot",
102-
"tensorinv",
103-
"tensorsolve",
104-
"trace",
105-
"vecdot",
106-
"vector_norm",
107-
]
108-
10974
# Need to set the module explicitly, because it's initially exposed by LAPACK
11075
# pybind11 extension and to add the docstrings
11176
LinAlgError.__module__ = "dpnp.linalg"

0 commit comments

Comments
 (0)