Overview

SciPy 1.10, released on January 4, 2023, introduces CubicHermiteSpline and improves existing interpolation methods.

Main Features

CubicHermiteSpline

The new CubicHermiteSpline class enables piecewise cubic interpolation with derivative control at data points, offering finer smoothing than classic splines.

python
from scipy.interpolate import CubicHermiteSpline
import numpy as np

x = np.array([0.0, 1.0, 2.0, 3.0])
y = np.array([0.0, 1.0, 0.0, 1.0])
dydx = np.array([1.0, 0.0, -1.0, 0.0])  # derivatives

spline = CubicHermiteSpline(x, y, dydx)
x_fine = np.linspace(0, 3, 50)
y_fine = spline(x_fine)
print(f'Interpolated max: {y_fine.max():.3f}')

Improved interpolation

The scipy.interpolate module gains improved performance and new options for multidimensional interpolation, including better support for irregular grids.

python
from scipy.interpolate import RegularGridInterpolator
import numpy as np

x = np.linspace(0, 1, 10)
y = np.linspace(0, 1, 10)
data = np.random.rand(10, 10)

interp = RegularGridInterpolator((x, y), data)
points = np.array([[0.5, 0.5], [0.2, 0.8]])
print(interp(points))

Sources