Overview
SciPy 1.6, released on January 3, 2021, brings improvements to sparse arrays and new interpolation methods.
Main Features
Sparse array improvements
The scipy.sparse module gains new arithmetic operations and better CSR/CSC format support for in-place operations. Matrix-vector multiplications are also faster.
python
from scipy import sparse
import numpy as np
# Create a 1000x1000 sparse matrix (1% filled)
matrix = sparse.random(1000, 1000, density=0.01, format='csr')
print(f'Non-zero elements: {matrix.nnz}') # ~10000
# Fast sparse matrix operations
result = matrix @ matrix.T # sparse matrix product
print(f'Shape: {result.shape}') # (1000, 1000)
# Efficient format conversion
csc = matrix.tocsc() # for column-wise access
print(f'Format: {csc.format}') # csc
New interpolation methods
The scipy.interpolate module adds new algorithms, including improved B-splines and monotone interpolation methods for irregular data.
python
from scipy.interpolate import make_interp_spline
import numpy as np
# Irregularly spaced measurement data
x = np.array([0, 1, 3, 5, 8, 10])
y = np.array([0, 0.8, 0.9, 0.2, -0.5, -0.1])
# Cubic B-spline interpolation
spline = make_interp_spline(x, y, k=3)
# Evaluate on a fine grid
x_fine = np.linspace(0, 10, 100)
y_fine = spline(x_fine)
print(f'Interpolated min: {y_fine.min():.2f}') # ~-0.58
