| 1404 | } |
| 1405 | |
| 1406 | static PyObject * |
| 1407 | array_partition(PyArrayObject *self, |
| 1408 | PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) |
| 1409 | { |
| 1410 | int axis=-1; |
| 1411 | int val; |
| 1412 | NPY_SELECTKIND sortkind = NPY_INTROSELECT; |
| 1413 | PyObject *order = NULL; |
| 1414 | PyArray_Descr *saved = NULL; |
| 1415 | PyArray_Descr *newd; |
| 1416 | PyArrayObject * ktharray; |
| 1417 | PyObject * kthobj; |
| 1418 | NPY_PREPARE_ARGPARSER; |
| 1419 | |
| 1420 | if (npy_parse_arguments("partition", args, len_args, kwnames, |
| 1421 | "kth", NULL, &kthobj, |
| 1422 | "|axis", &PyArray_PythonPyIntFromInt, &axis, |
| 1423 | "|kind", &PyArray_SelectkindConverter, &sortkind, |
| 1424 | "|order", NULL, &order, |
| 1425 | NULL, NULL, NULL) < 0) { |
| 1426 | return NULL; |
| 1427 | } |
| 1428 | |
| 1429 | if (order == Py_None) { |
| 1430 | order = NULL; |
| 1431 | } |
| 1432 | if (order != NULL) { |
| 1433 | PyObject *new_name; |
| 1434 | PyObject *_numpy_internal; |
| 1435 | saved = PyArray_DESCR(self); |
| 1436 | if (!PyDataType_HASFIELDS(saved)) { |
| 1437 | PyErr_SetString(PyExc_ValueError, "Cannot specify " \ |
| 1438 | "order when the array has no fields."); |
| 1439 | return NULL; |
| 1440 | } |
| 1441 | _numpy_internal = PyImport_ImportModule("numpy.core._internal"); |
| 1442 | if (_numpy_internal == NULL) { |
| 1443 | return NULL; |
| 1444 | } |
| 1445 | new_name = PyObject_CallMethod(_numpy_internal, "_newnames", |
| 1446 | "OO", saved, order); |
| 1447 | Py_DECREF(_numpy_internal); |
| 1448 | if (new_name == NULL) { |
| 1449 | return NULL; |
| 1450 | } |
| 1451 | newd = PyArray_DescrNew(saved); |
| 1452 | if (newd == NULL) { |
| 1453 | Py_DECREF(new_name); |
| 1454 | return NULL; |
| 1455 | } |
| 1456 | Py_DECREF(newd->names); |
| 1457 | newd->names = new_name; |
| 1458 | ((PyArrayObject_fields *)self)->descr = newd; |
| 1459 | } |
| 1460 | |
| 1461 | ktharray = (PyArrayObject *)PyArray_FromAny(kthobj, NULL, 0, 1, |
| 1462 | NPY_ARRAY_DEFAULT, NULL); |
| 1463 | if (ktharray == NULL) |
nothing calls this directly
no test coverage detected