0

I am trying to implement PchipInterpolator based on the link:

http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.PchipInterpolator.html

The code I am using is:

x = np.arange(0, 10)
y = np.exp(-x/3.0)
set_interp  =   scipy.interpolate.PchipInterpolator( x, y, extrapolate=True )

I get the error as:

TypeError: __init__() got an unexpected keyword argument 'extrapolate'

So, obviously I am implementing it the wrong way. I have tried numerous other ways to implement extrapolate but it fails.

Zanam
  • 4,607
  • 13
  • 67
  • 143
  • See this too http://stackoverflow.com/questions/2745329/how-to-make-scipy-interpolate-give-an-extrapolated-result-beyond-the-input-range – ᴀʀᴍᴀɴ Jan 07 '16 at 16:46
  • What version of numpy are you using? It is a pure python function, so you could use ipython or inspect to look at the constructor and its arguments for yourself. – talonmies Jan 07 '16 at 19:07

2 Answers2

1

PchipInterpolator was refactored in version 0.14, and that's when it has grown the extrapolate keyword.

Compare the docs for the version 0.13: http://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.interpolate.PchipInterpolator.html

and version 0.14: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.PchipInterpolator.html

(disclaimer: I was involved in that refactor)

Scipy 0.13 is quite old by now, best consider upgrading.

More recent scipy versions are slightly better in terms of consistency in interpolate. For one, all polynomial-based interpolators (PPoly, BPoly, Pchip and Akima) have the extrapolate keyword.

ev-br
  • 24,968
  • 9
  • 65
  • 78
0

Try this:

from scipy import interpolate
import numpy as np


x = np.arange(0, 10)
y = np.exp(-x/3.0)
set_interp  =   interpolate.PchipInterpolator( x, y, extrapolate=True )

I got no error

ᴀʀᴍᴀɴ
  • 4,443
  • 8
  • 37
  • 57
  • I still get the same error. My version:scipy.version.version Out[6]: '0.13.2'. What version are you using – Zanam Jan 07 '16 at 16:55
  • @user1243255 i didnt get error , see the link i commented under your question , maybe its solve your problem – ᴀʀᴍᴀɴ Jan 07 '16 at 16:56