ENH: vectorize interpolate
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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