Perform an indirect partition along the given axis using the algorithm specified by the `kind` keyword. It returns an array of indices of the same shape as `a` that index data along the given axis in partitioned order. .. versionadded:: 1.8.0 Parameters ----------
(a, kth, axis=-1, kind='introselect', order=None)
| 778 | |
| 779 | @array_function_dispatch(_argpartition_dispatcher) |
| 780 | def argpartition(a, kth, axis=-1, kind='introselect', order=None): |
| 781 | """ |
| 782 | Perform an indirect partition along the given axis using the |
| 783 | algorithm specified by the `kind` keyword. It returns an array of |
| 784 | indices of the same shape as `a` that index data along the given |
| 785 | axis in partitioned order. |
| 786 | |
| 787 | .. versionadded:: 1.8.0 |
| 788 | |
| 789 | Parameters |
| 790 | ---------- |
| 791 | a : array_like |
| 792 | Array to sort. |
| 793 | kth : int or sequence of ints |
| 794 | Element index to partition by. The k-th element will be in its |
| 795 | final sorted position and all smaller elements will be moved |
| 796 | before it and all larger elements behind it. The order of all |
| 797 | elements in the partitions is undefined. If provided with a |
| 798 | sequence of k-th it will partition all of them into their sorted |
| 799 | position at once. |
| 800 | |
| 801 | .. deprecated:: 1.22.0 |
| 802 | Passing booleans as index is deprecated. |
| 803 | axis : int or None, optional |
| 804 | Axis along which to sort. The default is -1 (the last axis). If |
| 805 | None, the flattened array is used. |
| 806 | kind : {'introselect'}, optional |
| 807 | Selection algorithm. Default is 'introselect' |
| 808 | order : str or list of str, optional |
| 809 | When `a` is an array with fields defined, this argument |
| 810 | specifies which fields to compare first, second, etc. A single |
| 811 | field can be specified as a string, and not all fields need be |
| 812 | specified, but unspecified fields will still be used, in the |
| 813 | order in which they come up in the dtype, to break ties. |
| 814 | |
| 815 | Returns |
| 816 | ------- |
| 817 | index_array : ndarray, int |
| 818 | Array of indices that partition `a` along the specified axis. |
| 819 | If `a` is one-dimensional, ``a[index_array]`` yields a partitioned `a`. |
| 820 | More generally, ``np.take_along_axis(a, index_array, axis=axis)`` |
| 821 | always yields the partitioned `a`, irrespective of dimensionality. |
| 822 | |
| 823 | See Also |
| 824 | -------- |
| 825 | partition : Describes partition algorithms used. |
| 826 | ndarray.partition : Inplace partition. |
| 827 | argsort : Full indirect sort. |
| 828 | take_along_axis : Apply ``index_array`` from argpartition |
| 829 | to an array as if by calling partition. |
| 830 | |
| 831 | Notes |
| 832 | ----- |
| 833 | See `partition` for notes on the different selection algorithms. |
| 834 | |
| 835 | Examples |
| 836 | -------- |
| 837 | One dimensional array: |
nothing calls this directly
no test coverage detected