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

Function arr_interp

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

Source from the content-addressed store, hash-verified

494#undef LIKELY_IN_CACHE_SIZE
495
496NPY_NO_EXPORT PyObject *
497arr_interp(PyObject *NPY_UNUSED(self), PyObject *const *args, Py_ssize_t len_args,
498 PyObject *kwnames)
499{
500
501 PyObject *fp, *xp, *x;
502 PyObject *left = NULL, *right = NULL;
503 PyArrayObject *afp = NULL, *axp = NULL, *ax = NULL, *af = NULL;
504 npy_intp i, lenx, lenxp;
505 npy_double lval, rval;
506 const npy_double *dy, *dx, *dz;
507 npy_double *dres, *slopes = NULL;
508
509 NPY_BEGIN_THREADS_DEF;
510
511 NPY_PREPARE_ARGPARSER;
512 if (npy_parse_arguments("interp", args, len_args, kwnames,
513 "x", NULL, &x,
514 "xp", NULL, &xp,
515 "fp", NULL, &fp,
516 "|left", NULL, &left,
517 "|right", NULL, &right,
518 NULL, NULL, NULL) < 0) {
519 return NULL;
520 }
521
522 afp = (PyArrayObject *)PyArray_ContiguousFromAny(fp, NPY_DOUBLE, 1, 1);
523 if (afp == NULL) {
524 return NULL;
525 }
526 axp = (PyArrayObject *)PyArray_ContiguousFromAny(xp, NPY_DOUBLE, 1, 1);
527 if (axp == NULL) {
528 goto fail;
529 }
530 ax = (PyArrayObject *)PyArray_ContiguousFromAny(x, NPY_DOUBLE, 0, 0);
531 if (ax == NULL) {
532 goto fail;
533 }
534 lenxp = PyArray_SIZE(axp);
535 if (lenxp == 0) {
536 PyErr_SetString(PyExc_ValueError,
537 "array of sample points is empty");
538 goto fail;
539 }
540 if (PyArray_SIZE(afp) != lenxp) {
541 PyErr_SetString(PyExc_ValueError,
542 "fp and xp are not of the same length.");
543 goto fail;
544 }
545
546 af = (PyArrayObject *)PyArray_SimpleNew(PyArray_NDIM(ax),
547 PyArray_DIMS(ax), NPY_DOUBLE);
548 if (af == NULL) {
549 goto fail;
550 }
551 lenx = PyArray_SIZE(ax);
552
553 dy = (const npy_double *)PyArray_DATA(afp);

Callers

nothing calls this directly

Calls 5

PyArray_NDIMFunction · 0.85
PyArray_DIMSFunction · 0.85
PyArray_DATAFunction · 0.85
binary_search_with_guessFunction · 0.85
PyArray_ReturnFunction · 0.85

Tested by

no test coverage detected