NumPy 2.1.0 Release Notes#

Highlights#

We’ll choose highlights for this release near the end of the release cycle.

Deprecations#

  • The fix_imports keyword argument in numpy.save is deprecated. Since NumPy 1.17, numpy.save uses a pickle protocol that no longer supports Python 2, and ignored fix_imports keyword. This keyword is kept only for backward compatibility. It is now deprecated.

(gh-26452)

Expired deprecations#

C API changes#

API symbols now hidden but customizable#

NumPy now defaults to hide the API symbols it adds to allow all NumPy API usage. This means that by default you cannot dynamically fetch the NumPy API from another library (this was never possible on windows).

If you are experiencing linking errors related to PyArray_API or PyArray_RUNTIME_VERSION, you can define the NPY_API_SYMBOL_ATTRIBUTE to opt-out of this change.

If you are experiencing problems due to an upstream header including NumPy, the solution is to make sure you #include "numpy/ndarrayobject.h" before their header and import NumPy yourself based on Including and importing the C API.

(gh-26103)

New Features#

Improvements#

histogram auto-binning now returns bin sizes >=1 for integer input data#

For integer input data, bin sizes smaller than 1 result in spurious empty bins. This is now avoided when the number of bins is computed using one of the algorithms provided by histogram_bin_edges.

(gh-12150)

Performance improvements and changes#

ma.cov and ma.corrcoef are now significantly faster#

The private function has been refactored along with ma.cov and ma.corrcoef. They are now significantly faster, particularly on large, masked arrays.

(gh-26285)

  • numpy.save now uses pickle protocol version 4 for saving arrays with object dtype, which allows for pickle objects larger than 4GB and improves saving speed by about 5% for large arrays.

(gh-26388)

Changes#

  • As numpy.vecdot is now a ufunc it has a less precise signature. This is due to the limitations of ufunc’s typing stub.

    (gh-26313)

ma.corrcoef may return a slightly different result#

A pairwise observation approach is currently used in ma.corrcoef to calculate the standard deviations for each pair of variables. This has been changed as it is being used to normalise the covariance, estimated using ma.cov, which does not consider the observations for each variable in a pairwise manner, rendering it unnecessary. The normalisation has been replaced by the more appropriate standard deviation for each variable, which significantly reduces the wall time, but will return slightly different estimates of the correlation coefficients in cases where the observations between a pair of variables are not aligned. However, it will return the same estimates in all other cases, including returning the same correlation matrix as corrcoef when using a masked array with no masked values.

(gh-26285)