Overview

SciPy 1.12, released on January 24, 2024, prepares NumPy 2.0 compatibility and adds new solvers in scipy.optimize.

Main Features

NumPy 2.0 preparation

SciPy 1.12 is compatible with NumPy 2.0 dev, easing the transition for the Python scientific ecosystem.

python
import scipy
import numpy as np

print(f'SciPy: {scipy.__version__}')   # 1.12.x
print(f'NumPy: {np.__version__}')       # compatible 1.x and 2.x

# Deprecated NumPy 2.0 APIs are updated
from scipy import sparse
m = sparse.eye(3, format='csr')
print(m.toarray())

New solvers

The scipy.optimize module gains new algorithms for linear programming and constrained optimization.

python
from scipy.optimize import milp, LinearConstraint, Bounds

# Mixed-integer linear programming (MILP)
c = [-1, -2]  # minimize -x - 2y
constraints = LinearConstraint([[1, 1], [1, 0]], ub=[4, 3])
integrality = [1, 1]  # integer variables

result = milp(c, constraints=constraints,
              integrality=integrality, bounds=Bounds(0, None))
print(result.x)  # [1.0, 3.0]

Sources