MCPcopy Create free account
hub / github.com/numpy/numpy / PyArray_ArgSort

Function PyArray_ArgSort

numpy/core/src/multiarray/item_selection.c:1662–1702  ·  view source on GitHub ↗

NUMPY_API * ArgSort an array */

Source from the content-addressed store, hash-verified

1660 * ArgSort an array
1661 */
1662NPY_NO_EXPORT PyObject *
1663PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
1664{
1665 PyArrayObject *op2;
1666 PyArray_ArgSortFunc *argsort = NULL;
1667 PyObject *ret;
1668
1669 argsort = PyArray_DESCR(op)->f->argsort[which];
1670
1671 if (argsort == NULL) {
1672 if (PyArray_DESCR(op)->f->compare) {
1673 switch (which) {
1674 default:
1675 case NPY_QUICKSORT:
1676 argsort = npy_aquicksort;
1677 break;
1678 case NPY_HEAPSORT:
1679 argsort = npy_aheapsort;
1680 break;
1681 case NPY_STABLESORT:
1682 argsort = npy_atimsort;
1683 break;
1684 }
1685 }
1686 else {
1687 PyErr_SetString(PyExc_TypeError,
1688 "type does not have compare function");
1689 return NULL;
1690 }
1691 }
1692
1693 op2 = (PyArrayObject *)PyArray_CheckAxis(op, &axis, 0);
1694 if (op2 == NULL) {
1695 return NULL;
1696 }
1697
1698 ret = _new_argsortlike(op2, axis, argsort, NULL, NULL, 0);
1699
1700 Py_DECREF(op2);
1701 return ret;
1702}
1703
1704
1705/*NUMPY_API

Callers 1

array_argsortFunction · 0.85

Calls 3

PyArray_DESCRFunction · 0.85
PyArray_CheckAxisFunction · 0.85
_new_argsortlikeFunction · 0.85

Tested by

no test coverage detected