numpy / numpy/numpy

ENH: vectorize interpolate

Open
#10,439 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

01 - Enhancement component: numpy.lib
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Right now, interp handles scalar-valued functions well. When throwing a vector-valued function at it like

import numpy

x = numpy.array([0.5, 1.5])
xp = numpy.array([0.0, 1.0, 2.0])
# fp = numpy.random.rand(3)  # works
fp = numpy.random.rand(3, 4, 5)

numpy.interp(x, xp, fp)

it bails out with

ValueError: object too deep for desired array

When looking at the code for interp, it almost seems it was meant to do that already.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the interp implementation in numpy/lib/function_base.py around the linked entry point and reproduce the issue's vector-valued example. Determine the expected shape and values for multidimensional fp, then verify that numpy.interp supports that behavior with focused tests; done means the shown vector-valued call no longer raises the depth error.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.