NumPy 2.5.0 Release Notes#

Highlights#

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

Deprecations#

Setting the shape attribute is deprecated#

Setting the shape attribute is now deprecated since mutating an array is unsafe if an array is shared, especially by multiple threads. As an alternative, you can create a new view via np.reshape or np.ndarray.reshape. For example: x = np.arange(15); x = np.reshape(x, (3, 5)). To ensure no copy is made from the data, one can use np.reshape(..., copy=False).

Directly setting the shape on an array is discouraged, but for cases where it is difficult to work around, e.g., in __array_finalize__ possible with the private method np.ndarray._set_shape.

(gh-29536)

Resizing a Numpy array inplace is deprecated#

Resizing a Numpy array inplace is deprecated since mutating an array is unsafe if an array is shared, especially by multiple threads. As an alternative, you can create a resized array via np.resize.

(gh-30181)

Expired deprecations#

  • numpy.distutils has been removed

    (gh-30340)

  • Passing None as dtype to np.finfo will now raise a TypeError (deprecated since 1.25)

    (gh-30460)

  • numpy.cross no longer supports 2-dimensional vectors (deprecated since 2.0)

    (gh-30461)

  • numpy._core.numerictypes.maximum_sctype has been removed (deprecated since 2.0)

    (gh-30462)

  • numpy.row_stack has been removed in favor of numpy.vstack (deprecated since 2.0).

  • get_array_wrap has been removed (deprecated since 2.0).

    (gh-30463)

  • recfromtxt and recfromcsv have been removed from numpy.lib._npyio in favor of numpy.genfromtxt (deprecated since 2.0).

    (gh-30467)

  • The numpy.chararray re-export of numpy.char.chararray has been removed (deprecated since 2.0).

    (gh-30604)

  • bincount now raises a TypeError for non-integer inputs (deprecated since 2.1).

    (gh-30610)

  • The numpy.lib.math alias for the standard library math module has been removed (deprecated since 1.25).

    (gh-30612)

  • Data type alias 'a' was removed in favor of 'S' (deprecated since 2.0).

    (gh-30613)

  • _add_newdoc_ufunc(ufunc, newdoc) has been removed in favor of ufunc.__doc__ = newdoc (deprecated in 2.2)

    (gh-30614)

Compatibility notes#

MSVC support#

NumPy now requires minimum MSVC 19.35 toolchain version on Windows platforms. This corresponds to Visual Studio 2022 version 17.5 Preview 2 or newer.

(gh-30489)

New Features#

Pixi package definitions#

Pixi package definitions have been added for different kinds of from-source builds of NumPy. These can be used in downstream Pixi workspaces via the pixi-build feature.

Definitions for both default and AddressSanitizer-instrumented (asan) builds are available in the source code under the pixi-packages/ directory.

linux-64 and osx-arm64 platforms are supported.

(gh-30381)

Typing improvements and changes#

numpy.linalg typing improvements and preliminary shape-typing support#

Input and output dtypes for numpy.linalg functions are now more precise. Several of these functions also gain preliminary shape-typing support while remaining backward compatible. For example, the return type of numpy.linalg.matmul now depends on the shape-type of its inputs, or fall back to the backward-compatible return type if the shape-types are unknown at type-checking time. Because of limitations in Python’s type system and current type-checkers, shape-typing cannot cover every situation and is often only implemented for the most common lower-rank cases.

(gh-30480)

numpy.ma typing annotations#

The numpy.ma module is now fully covered by typing annotations. This includes annotations for masked arrays, masks, and various functions and methods. With this, NumPy has achieved 100% typing coverage across all its submodules.

(gh-30566)