{ } Raw JSON

bundles / scipy 1.17.1 / scipy / _lib / array_api_extra / _delegation / argpartition

function

scipy._lib.array_api_extra._delegation:argpartition

source: /scipy/_lib/array_api_extra/_delegation.py :878

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 : Array

Input array.

kth : int

Element index to partition by.

axis : int, optional

Axis along which to partition. The default is -1 (the last axis). If None, the flattened array is used.

xp : array_namespace, optional

The standard-compatible namespace for x. Default: infer.

Returns

: index_array

Array of indices that partition a along 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