Skip to content

Commit d5dfee4

Browse files
author
Vahid Tavanashad
committed
address comments
1 parent 356553e commit d5dfee4

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

dpnp/dpnp_iface.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"as_usm_ndarray",
6262
"check_limitations",
6363
"check_supported_arrays_type",
64-
"convert_single_elem_array_to_scalar",
6564
"default_float_type",
6665
"from_dlpack",
6766
"get_dpnp_descriptor",
@@ -407,15 +406,6 @@ def check_supported_arrays_type(*arrays, scalar_type=False, all_scalars=False):
407406
return True
408407

409408

410-
def convert_single_elem_array_to_scalar(obj, keepdims=False):
411-
"""Convert array with single element to scalar."""
412-
413-
if (obj.ndim > 0) and (obj.size == 1) and (keepdims is False):
414-
return obj.dtype.type(obj[0])
415-
416-
return obj
417-
418-
419409
def default_float_type(device=None, sycl_queue=None):
420410
"""
421411
Return a floating type used by default in DPNP depending on device

dpnp/dpnp_iface_sorting.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ def _wrap_sort_argsort(
7070
raise NotImplementedError(
7171
"kind keyword argument can only be None or 'stable'."
7272
)
73-
if stable is None or not stable:
74-
raise NotImplementedError(
75-
"stable keyword argument is only supported with its default value."
76-
)
7773

7874
usm_a = dpnp.get_usm_ndarray(a)
7975
if axis is None:
@@ -101,6 +97,12 @@ def argsort(a, axis=-1, kind=None, order=None, *, stable=True):
10197
kind : {None, "stable"}, optional
10298
Sorting algorithm. Default is ``None``, which is equivalent to
10399
``"stable"``. Unlike NumPy, no other option is accepted here.
100+
stable : {None, bool}, optional
101+
Sort stability. If ``True``, the returned array will maintain
102+
the relative order of ``a`` values which compare as equal.
103+
The same behavior applies when set to ``False`` or ``None``.
104+
Internally, this option selects ``kind="stable"``.
105+
Default: ``None``.
104106
105107
Returns
106108
-------
@@ -118,9 +120,10 @@ def argsort(a, axis=-1, kind=None, order=None, *, stable=True):
118120
119121
Limitations
120122
-----------
121-
Parameters `order` and `stable` are only supported with their default
122-
values. Parameter `kind` can only be ``None`` or ``"stable"`` which are
123-
equivalent. Otherwise ``NotImplementedError`` exception will be raised.
123+
Parameters `order` is only supported with its default value.
124+
Parameter `kind` can only be ``None`` or ``"stable"`` which are equivalent.
125+
Otherwise ``NotImplementedError`` exception will be raised.
126+
124127
See Also
125128
--------
126129
:obj:`dpnp.ndarray.argsort` : Equivalent method.
@@ -216,6 +219,12 @@ def sort(a, axis=-1, kind=None, order=None, *, stable=True):
216219
kind : {None, "stable"}, optional
217220
Sorting algorithm. Default is ``None``, which is equivalent to
218221
``"stable"``. Unlike NumPy, no other option is accepted here.
222+
stable : {None, bool}, optional
223+
Sort stability. If ``True``, the returned array will maintain
224+
the relative order of ``a`` values which compare as equal.
225+
The same behavior applies when set to ``False`` or ``None``.
226+
Internally, this option selects ``kind="stable"``.
227+
Default: ``None``.
219228
220229
Returns
221230
-------
@@ -229,9 +238,9 @@ def sort(a, axis=-1, kind=None, order=None, *, stable=True):
229238
230239
Limitations
231240
-----------
232-
Parameters `order` and `stable` are only supported with their default
233-
values. Parameter `kind` can only be ``None`` or ``"stable"`` which are
234-
equivalent. Otherwise ``NotImplementedError`` exception will be raised.
241+
Parameters `order` is only supported with its default value.
242+
Parameter `kind` can only be ``None`` or ``"stable"`` which are equivalent.
243+
Otherwise ``NotImplementedError`` exception will be raised.
235244
236245
See Also
237246
--------

dpnp/dpnp_iface_statistics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,8 @@ def median(a, axis=None, out=None, overwrite_input=False, keepdims=False):
668668
overwrite_input : bool, optional
669669
If ``True``, then allow use of memory of input array `a` for
670670
calculations. The input array will be modified by the call to
671-
``median``. This will save memory when you do not need to preserve
672-
the contents of the input array. Treat the input as undefined,
671+
:obj:`dpnp.median`. This will save memory when you do not need to
672+
preserve the contents of the input array. Treat the input as undefined,
673673
but it will probably be fully or partially sorted.
674674
Default: ``False``.
675675
keepdims : {None, bool}, optional
@@ -711,18 +711,21 @@ def median(a, axis=None, out=None, overwrite_input=False, keepdims=False):
711711
[ 3, 2, 1]])
712712
>>> np.median(a)
713713
array(3.5)
714+
714715
>>> np.median(a, axis=0)
715716
array([6.5, 4.5, 2.5])
716717
>>> np.median(a, axis=1)
717718
array([7., 2.])
718719
>>> np.median(a, axis=(0, 1))
719720
array(3.5)
721+
720722
>>> m = np.median(a, axis=0)
721723
>>> out = np.zeros_like(m)
722724
>>> np.median(a, axis=0, out=m)
723725
array([6.5, 4.5, 2.5])
724726
>>> m
725727
array([6.5, 4.5, 2.5])
728+
726729
>>> b = a.copy()
727730
>>> np.median(b, axis=1, overwrite_input=True)
728731
array([7., 2.])

tests/test_mathematical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2470,7 +2470,7 @@ def test_out(self, func_params, dtype):
24702470
# numpy.ceil, numpy.floor, numpy.trunc always return float dtype for
24712471
# NumPy < 2.0.0 while output has the dtype of input for NumPy >= 2.0.0
24722472
# (dpnp follows the latter behavior except for boolean dtype where it
2473-
# return int8)
2473+
# returns int8)
24742474
if (
24752475
numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
24762476
or dtype == numpy.bool

0 commit comments

Comments
 (0)