bundles / scipy 1.17.1 / scipy / _lib / array_api_extra / _delegation / argpartition
function
scipy._lib.array_api_extra._delegation:argpartition
Signature
def argpartition ( a : Array , kth : int , / , axis : int | None = -1 , * , xp : ModuleType | None = None ) → Array Summary
Perform an indirect partition along the given axis.
Extended Summary
It returns an array of indices of the same shape as a that index data along the given axis in partitioned order.
Parameters
a: ArrayInput array.
kth: intElement index to partition by.
axis: int, optionalAxis along which to partition. The default is
-1(the last axis). IfNone, the flattened array is used.xp: array_namespace, optionalThe standard-compatible namespace for
x. Default: infer.
Returns
: index_arrayArray of indices that partition
aalong the specified axis.
Notes
If xp implements argpartition or an equivalent function e.g. topk for torch), complexity will likely be O(n). If not, this function simply calls xp.argsort and complexity is O(n log n).
Aliases
-
scipy.differentiate.xpx.argpartition