Skip to content

Commit 6f6855b

Browse files
authored
Add positional-only and keyword-only parameter markers to ufuncs (#2660)
The PR add missing the positional-only and the keyword-only parameter markers, aligning signature of the ufuncs with NumPy.
1 parent c9afa82 commit 6f6855b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
3030
* Changed the license from `BSD-2-Clause` to `BSD-3-Clause` [#2593](https://github.com/IntelPython/dpnp/pull/2593)
3131
* Defined explicit versions range of the Python interpreter which is needed during the build [#2634](https://github.com/IntelPython/dpnp/pull/2634)
3232
* Aligned documentation with NumPy and CuPy style by using short function names [#2633](https://github.com/IntelPython/dpnp/pull/2633)
33+
* Added the missing positional-only and keyword-only parameter markers to bring the ufunc signatures into alignment with NumPy [#2660](https://github.com/IntelPython/dpnp/pull/2660)
3334

3435
### Deprecated
3536

dpnp/dpnp_algo/dpnp_elementwise_common.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def _call_func(src, dst, sycl_queue, depends=None):
149149
def __call__(
150150
self,
151151
x,
152+
/,
152153
out=None,
154+
*,
153155
where=True,
154156
order="K",
155157
dtype=None,
@@ -542,7 +544,9 @@ def __call__(
542544
self,
543545
x1,
544546
x2,
547+
/,
545548
out=None,
549+
*,
546550
where=True,
547551
order="K",
548552
dtype=None,
@@ -746,7 +750,7 @@ def __init__(
746750
mkl_impl_fn=mkl_impl_fn,
747751
)
748752

749-
def __call__(self, x, deg=False, out=None, order="K"):
753+
def __call__(self, x, /, deg=False, *, out=None, order="K"):
750754
res = super().__call__(x, out=out, order=order)
751755
if deg is True:
752756
res *= 180 / dpnp.pi
@@ -770,7 +774,7 @@ def __init__(
770774
docs,
771775
)
772776

773-
def __call__(self, x, out=None, order="K"):
777+
def __call__(self, x, /, out=None, *, order="K"):
774778
if not dpnp.is_supported_array_type(x):
775779
pass # pass to raise error in main implementation
776780
elif dpnp.issubdtype(x.dtype, dpnp.inexact):
@@ -816,7 +820,7 @@ def __init__(
816820
mkl_impl_fn=mkl_impl_fn,
817821
)
818822

819-
def __call__(self, x, out=None, order="K"):
823+
def __call__(self, x, /, *, out=None, order="K"):
820824
return super().__call__(x, out=out, order=order)
821825

822826

@@ -837,7 +841,7 @@ def __init__(
837841
docs,
838842
)
839843

840-
def __call__(self, x, out=None, order="K"):
844+
def __call__(self, x, /, *, out=None, order="K"):
841845
return super().__call__(x, out=out, order=order)
842846

843847

@@ -858,7 +862,7 @@ def __init__(
858862
docs,
859863
)
860864

861-
def __call__(self, x, out=None, order="K"):
865+
def __call__(self, x, /, *, out=None, order="K"):
862866
if numpy.iscomplexobj(x):
863867
return super().__call__(x, out=out, order=order)
864868
return x
@@ -885,7 +889,7 @@ def __init__(
885889
mkl_impl_fn=mkl_impl_fn,
886890
)
887891

888-
def __call__(self, x, decimals=0, out=None, dtype=None):
892+
def __call__(self, x, /, decimals=0, out=None, *, dtype=None):
889893
if decimals != 0:
890894
x_usm = dpnp.get_usm_ndarray(x)
891895
out_usm = None if out is None else dpnp.get_usm_ndarray(out)
@@ -928,7 +932,7 @@ def __init__(
928932
docs,
929933
)
930934

931-
def __call__(self, x, out=None, order="K"):
935+
def __call__(self, x, /, *, out=None, order="K"):
932936
return super().__call__(x, out=out, order=order)
933937

934938

0 commit comments

Comments
 (0)