Overview
NumPy 1.24, released on December 19, 2022, advances toward Array API standard compliance and deprecates several legacy behaviors.
Main Features
Array API standard
NumPy progresses toward Array API standard compliance, enabling interoperability with other array libraries like CuPy and JAX.
python
import numpy as np
# Using the Array API namespace
xp = np # interchangeable with cupy, jax.numpy, etc.
a = xp.asarray([1.0, 2.0, 3.0])
b = xp.asarray([4.0, 5.0, 6.0])
c = xp.add(a, b)
print(c) # [5. 7. 9.]
Deprecations
Several legacy behaviors are deprecated, including implicit type conversions that may lose precision.
python
import numpy as np
# Explicit conversion recommended
a = np.array([1.5, 2.7, 3.9])
# Recommended: explicit conversion
b = a.astype(np.int64) # explicit
print(b) # [1 2 3]
# Deprecated: implicit conversion
# c = np.array([1.5, 2.7], dtype=np.int64) # warning
