accept kind as kwargs in sort/argsort
@@ -4,7 +4,7 @@ import numpy
from cupy.cuda import thrust
-def sort(a, axis=-1):
+def sort(a, axis=-1, kind=None):
"""Returns a sorted copy of an array with a stable sorting algorithm.
Args:
@@ -12,6 +12,8 @@ def sort(a, axis=-1):
axis (int or None): Axis along which to sort. Default is -1, which
means sort along the last axis. If None is supplied, the array is
flattened before sorting.
+ kind: Default is `None`, which is equivalent to 'stable'. Unlike in
+ NumPy any other options are not accepted here.
Returns:
cupy.ndarray: Array of the same type and shape as ``a``.
@@ -24,6 +26,8 @@ def sort(a, axis=-1):
.. seealso:: :func:`numpy.sort`
"""
+ if kind is not None and kind != 'stable':
+ raise ValueError("kind can only be None or 'stable'")
if axis is None:
ret = a.flatten()
axis = -1
@@ -84,7 +88,7 @@ def lexsort(keys):
return idx_array
-def argsort(a, axis=-1):
+def argsort(a, axis=-1, kind=None):
"""Returns the indices that would sort an array with a stable sorting.
Args:
@@ -92,6 +96,8 @@ def argsort(a, axis=-1):
axis (int or None): Axis along which to sort. Default is -1, which
means sort along the last axis. If None is supplied, the array is
flattened before sorting.
+ kind: Default is `None`, which is equivalent to 'stable'. Unlike in
+ NumPy any other options are not accepted here.
Returns:
cupy.ndarray: Array of indices that sort ``a``.
@@ -103,6 +109,8 @@ def argsort(a, axis=-1):
.. seealso:: :func:`numpy.argsort`
"""
+ if kind is not None and kind != 'stable':
+ raise ValueError("kind can only be None or 'stable'")
return a.argsort(axis=axis)
