numpy / numpy/numpy

BUG interp wrong if input xp isn't sorted

Open
#10,448 21 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

MWE:

import numpy

xp = [0.0, 1.0]
fp = [0.2, 0.3]
print(numpy.interp(0.5, xp, fp))  # 0.25, correct

xp = [1.0, 0.0]
fp = [0.3, 0.2]
print(numpy.interp(0.5, xp, fp))  # 0.2, WRONG

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 at the numpy.interp entry point and reproduce the issue's MWE with ascending and descending xp. Inspect how xp ordering is handled and determine the intended behavior for unsorted input from the surrounding implementation and discussion. Done means the behavior is consistent for the reported case and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.