Internal function to expose check_array_monotonic to python */
| 230 | |
| 231 | /* Internal function to expose check_array_monotonic to python */ |
| 232 | NPY_NO_EXPORT PyObject * |
| 233 | arr__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 |
nothing calls this directly
no test coverage detected