Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
10 changes: 0 additions & 10 deletions dpnp/dpnp_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"as_usm_ndarray",
"check_limitations",
"check_supported_arrays_type",
"convert_single_elem_array_to_scalar",
"default_float_type",
"from_dlpack",
"get_dpnp_descriptor",
Expand Down Expand Up @@ -407,15 +406,6 @@ def check_supported_arrays_type(*arrays, scalar_type=False, all_scalars=False):
return True


def convert_single_elem_array_to_scalar(obj, keepdims=False):
"""Convert array with single element to scalar."""

if (obj.ndim > 0) and (obj.size == 1) and (keepdims is False):
return obj.dtype.type(obj[0])

return obj


def default_float_type(device=None, sycl_queue=None):
"""
Return a floating type used by default in DPNP depending on device
Expand Down
29 changes: 19 additions & 10 deletions dpnp/dpnp_iface_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ def _wrap_sort_argsort(
raise NotImplementedError(
"kind keyword argument can only be None or 'stable'."
)
if stable is None or not stable:
raise NotImplementedError(
"stable keyword argument is only supported with its default value."
)

usm_a = dpnp.get_usm_ndarray(a)
if axis is None:
Expand Down Expand Up @@ -101,6 +97,12 @@ def argsort(a, axis=-1, kind=None, order=None, *, stable=True):
kind : {None, "stable"}, optional
Sorting algorithm. Default is ``None``, which is equivalent to
``"stable"``. Unlike NumPy, no other option is accepted here.
stable : {None, bool}, optional
Sort stability. If ``True``, the returned array will maintain
the relative order of ``a`` values which compare as equal.
The same behavior applies when set to ``False`` or ``None``.
Internally, this option selects ``kind="stable"``.
Default: ``None``.

Returns
-------
Expand All @@ -118,9 +120,10 @@ def argsort(a, axis=-1, kind=None, order=None, *, stable=True):

Limitations
-----------
Parameters `order` and `stable` are only supported with their default
values. Parameter `kind` can only be ``None`` or ``"stable"`` which are
equivalent. Otherwise ``NotImplementedError`` exception will be raised.
Parameters `order` is only supported with its default value.
Parameter `kind` can only be ``None`` or ``"stable"`` which are equivalent.
Otherwise ``NotImplementedError`` exception will be raised.

See Also
--------
:obj:`dpnp.ndarray.argsort` : Equivalent method.
Expand Down Expand Up @@ -216,6 +219,12 @@ def sort(a, axis=-1, kind=None, order=None, *, stable=True):
kind : {None, "stable"}, optional
Sorting algorithm. Default is ``None``, which is equivalent to
``"stable"``. Unlike NumPy, no other option is accepted here.
stable : {None, bool}, optional
Sort stability. If ``True``, the returned array will maintain
the relative order of ``a`` values which compare as equal.
The same behavior applies when set to ``False`` or ``None``.
Internally, this option selects ``kind="stable"``.
Default: ``None``.

Returns
-------
Expand All @@ -229,9 +238,9 @@ def sort(a, axis=-1, kind=None, order=None, *, stable=True):

Limitations
-----------
Parameters `order` and `stable` are only supported with their default
values. Parameter `kind` can only be ``None`` or ``"stable"`` which are
equivalent. Otherwise ``NotImplementedError`` exception will be raised.
Parameters `order` is only supported with its default value.
Parameter `kind` can only be ``None`` or ``"stable"`` which are equivalent.
Otherwise ``NotImplementedError`` exception will be raised.

See Also
--------
Expand Down
7 changes: 5 additions & 2 deletions dpnp/dpnp_iface_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ def median(a, axis=None, out=None, overwrite_input=False, keepdims=False):
overwrite_input : bool, optional
If ``True``, then allow use of memory of input array `a` for
calculations. The input array will be modified by the call to
``median``. This will save memory when you do not need to preserve
the contents of the input array. Treat the input as undefined,
:obj:`dpnp.median`. This will save memory when you do not need to
preserve the contents of the input array. Treat the input as undefined,
but it will probably be fully or partially sorted.
Default: ``False``.
keepdims : {None, bool}, optional
Expand Down Expand Up @@ -711,18 +711,21 @@ def median(a, axis=None, out=None, overwrite_input=False, keepdims=False):
[ 3, 2, 1]])
>>> np.median(a)
array(3.5)

>>> np.median(a, axis=0)
array([6.5, 4.5, 2.5])
>>> np.median(a, axis=1)
array([7., 2.])
>>> np.median(a, axis=(0, 1))
array(3.5)

>>> m = np.median(a, axis=0)
>>> out = np.zeros_like(m)
>>> np.median(a, axis=0, out=m)
array([6.5, 4.5, 2.5])
>>> m
array([6.5, 4.5, 2.5])

>>> b = a.copy()
>>> np.median(b, axis=1, overwrite_input=True)
array([7., 2.])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,7 @@ def test_out(self, func_params, dtype):
# numpy.ceil, numpy.floor, numpy.trunc always return float dtype for
# NumPy < 2.0.0 while output has the dtype of input for NumPy >= 2.0.0
# (dpnp follows the latter behavior except for boolean dtype where it
# return int8)
# returns int8)
if (
numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
or dtype == numpy.bool
Expand Down
Loading