Migrating to NumPy v2.4.0rc1
Version v2.4.0rc1 introduces 1 breaking change. This guide details how to update your code.
Released: 12/3/2025
1
Breaking Changes
20
Migration Steps
35
Affected Symbols
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
numpy.ndarray.stridesnumpy.maximumnumpy.minimumnumpy.dtypenp.testing.assert_warnsnp.testing.suppress_warningsnumpy.fixnumpy.ndarray.shapenumpy.lib.user_array.containernumpy.linalg.linalgnumpy.fft.helpernumpy.percentilenumpy.nanpercentilenumpy.quantilenumpy.nanquantilenumpy.in1dnumpy.isinnumpy.ndindex.ndincrnumpy.savendarray.ctypes._ctypes.get_datandarray.ctypes._ctypes.datandarray.ctypes._ctypes.get_shapendarray.ctypes._ctypes.shapendarray.ctypes._ctypes.get_stridesndarray.ctypes._ctypes.stridesndarray.ctypes._ctypes.get_as_parameterndarray.ctypes._ctypes._as_parameter_numpy.reshapenumpy.trapznumpy.trapezoiddispnumpy.corrcoefnumpy.ma.mrecords.fromtextfilenumpy.array2stringnumpy.sumBreaking Changes
●Issue #1
Conversion of an array with ndim > 0 to a scalar now raises TypeError.
✓Solution
Ensure you extract a single element from your array before performing this operation.
Migration Steps
- 1If you were setting the `strides` attribute, switch to using `np.lib.stride_tricks.strided_window_view`, `np.lib.stride_tricks.as_strided`, or the `np.ndarray` constructor to create a new view.
- 2When using `np.maximum` or `np.minimum`, always specify the output array using the keyword argument `out=c` instead of passing it positionally.
- 3Ensure the `align=` argument passed to `np.dtype()` is a boolean, and preferably pass it as a keyword argument.
- 4Replace usage of `np.testing.assert_warns` and `np.testing.suppress_warnings` with standard Python `warnings` context managers or `pytest` fixtures.
- 5Replace calls to `numpy.fix` with `numpy.trunc`.
- 6Instead of modifying `ndarray.shape` in place, use `numpy.reshape` to create a new array shape.
- 7If you were relying on implicit scalar conversion from an array with ndim > 0, you must now explicitly extract the single element (e.g., `arr.item()`).
- 8Update imports: use `numpy.linalg` instead of `numpy.linalg.linalg`, and `numpy.fft` instead of `numpy.fft.helper`.
- 9Replace the `interpolation` parameter with the `method` parameter in quantile and percentile functions.
- 10Replace calls to `numpy.in1d` with `numpy.isin`.
- 11Replace calls to `ndindex.ndincr()` with `next(ndindex)`.
- 12Remove the `fix_imports` parameter from `numpy.save` calls.
- 13Update calls to `ndarray.ctypes` methods: use `.data`, `.shape`, `.strides`, or `._as_parameter_` instead of the removed `get_*` methods.
- 14Update calls to `numpy.reshape` to use positional arguments or the `shape=` keyword argument instead of the removed `newshape` parameter.
- 15Replace calls to `numpy.trapz` with `numpy.trapezoid` or functions from `scipy.integrate`.
- 16Replace the `disp` function with custom printing logic.
- 17Remove the unused `bias` and `ddof` arguments from `numpy.corrcoef`.
- 18Replace the `delimitor` parameter with `delimiter` in `numpy.ma.mrecords.fromtextfile()`.
- 19Update calls to `numpy.array2string` to use keyword arguments for parameters following `style` (which is removed), or remove the `style` argument entirely.
- 20When summing a generator, wrap it in `np.fromiter(generator)` before passing to `np.sum`, or use the built-in `sum()`.
Release Summary
NumPy 2.4.0 introduces annotation improvements, a new 'same_value' casting option, and several new APIs for user dtypes. This release also removes numerous long-deprecated features and enforces stricter behavior for scalar conversion.
Need More Details?
View the full release notes and all changes for NumPy v2.4.0rc1.
View Full Changelog