Overview
NumPy 1.25, released on June 18, 2023, improves Array API standard compatibility and continues type modernization.
Main Features
Improved Array API
NumPy 1.25 progresses toward Array API standard compliance, facilitating interoperability with CuPy, JAX, and other numerical computing libraries.
python
import numpy as np
# Array API namespace
xp = np # Array API compatible
# Portable code across NumPy, CuPy, JAX
def normalize(x):
xp = x.__array_namespace__()
return (x - xp.mean(x)) / xp.std(x)
data = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
print(normalize(data))
Type modernization
Type promotion handling has been improved to be more predictable, and new deprecation warnings prepare for version 2.0 changes.
python
import numpy as np
# More predictable type promotion
a = np.array([1, 2, 3], dtype=np.int32)
b = np.array([1.0, 2.0, 3.0], dtype=np.float32)
# Result is float64 (clear promotion)
c = a + b
print(c.dtype) # float64
# New: explicit control
d = np.add(a, b, dtype=np.float32)
print(d.dtype) # float32
