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

Function arr__monotonicity

numpy/core/src/multiarray/compiled_base.c:232–266  ·  view source on GitHub ↗

Internal function to expose check_array_monotonic to python */

Source from the content-addressed store, hash-verified

230
231/* Internal function to expose check_array_monotonic to python */
232NPY_NO_EXPORT PyObject *
233arr__monotonicity(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
234{
235 static char *kwlist[] = {"x", NULL};
236 PyObject *obj_x = NULL;
237 PyArrayObject *arr_x = NULL;
238 long monotonic;
239 npy_intp len_x;
240 NPY_BEGIN_THREADS_DEF;
241
242 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|_monotonicity", kwlist,
243 &obj_x)) {
244 return NULL;
245 }
246
247 /*
248 * TODO:
249 * `x` could be strided, needs change to check_array_monotonic
250 * `x` is forced to double for this check
251 */
252 arr_x = (PyArrayObject *)PyArray_FROMANY(
253 obj_x, NPY_DOUBLE, 1, 1, NPY_ARRAY_CARRAY_RO);
254 if (arr_x == NULL) {
255 return NULL;
256 }
257
258 len_x = PyArray_SIZE(arr_x);
259 NPY_BEGIN_THREADS_THRESHOLDED(len_x)
260 monotonic = check_array_monotonic(
261 (const double *)PyArray_DATA(arr_x), len_x);
262 NPY_END_THREADS
263 Py_DECREF(arr_x);
264
265 return PyLong_FromLong(monotonic);
266}
267
268/*
269 * Returns input array with values inserted sequentially into places

Callers

nothing calls this directly

Calls 2

check_array_monotonicFunction · 0.85
PyArray_DATAFunction · 0.85

Tested by

no test coverage detected