question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`interp1d` behaviour inconsistent with Numpy's?

See original GitHub issue

Scipy interpolator returns nan if one of the neighbor is a nan even when interpolation is not actually needed. This looks inconsistent with Numpy’s behaviour :

>>> import numpy as np
>>> from scipy.interpolate import interp1d
>>> np.interp([0,1,2], xp=[0,1,2], fp=[np.nan,0,1])
array([nan,  0.,  1.])
>>> interp1d([0, 1, 2], [np.nan, 0, 1])([0,1,2])
array([nan, nan,  1.])

Is that an expected behaviour ?

Thanks a lot,

Version information :

>>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
1.6.0 1.19.4 sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ev-brcommented, Aug 20, 2021

Reopening until @mathisc confirms that gh-14601 fixes the original issue or comes up with a fix, as per https://github.com/scipy/scipy/issues/14531#issuecomment-902205813

1reaction
ev-brcommented, Aug 18, 2021

Yeah, this should keep backwards compatibility, including dtypes

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interpolation behaviour inconsistent with numpy? · Issue #5664
Hey all, When running dataset.interp(time=dataset.time) fills with np.nan if one of the neighbor is a np.nan even when interpolation is not ...
Read more >
Scipys interp1d and infinities - Stack Overflow
When interpolating linearly with scipy.interpolate.interp1d I encounter the following behaviour: from ...
Read more >
scipy.interpolate.interp1d — SciPy v1.9.3 Manual
An object-oriented wrapper of the FITPACK routines. Calling interp1d with NaNs present in input values results in undefined behaviour. Input values x and...
Read more >
Why is the behavior when assigning to values inconsistent?
[Solved]-Why is the behavior when assigning to values inconsistent?-numpy ... Why does interp1d in scipy give a NaN when the first 2 values...
Read more >
Scipy 2d Interpolation - Accademia e sartoria le filatrici
How to do two dimensional interpolation using SciPy in python. ... SciPy. import numpy as np import scipy. interpolate import interp1d f1 =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found