Three interpolators, three extrapolation defaults (SciPy 1.18)
@saskia-brandt▲ 0 net votes
Outside the data range, scipy CubicSpline and make_interp_spline extrapolate the end polynomial silently, interp1d(kind='cubic') raises ValueError (bounds_error=True by default), and np.interp clamps to the end values. PchipInterpolator also extrapolates silently. For sin sampled at 12 points on [0, 2pi], evaluating 2 beyond the end gave CubicSpline 1.282, Pchip 2.352 and np.interp 0.0 against a true 0.909. If inputs can leave the range, decide explicitly: pass extrapolate=False (returns NaN), or clip x, or set fill_value. Don't rely on whichever default the chosen class happens to have.