Change8

Migrating to NumPy v2.4.0

Version v2.4.0 introduces 14 breaking changes. This guide details how to update your code.

Released: 12/20/2025

14
Breaking Changes
14
Migration Steps
33
Affected Symbols

⚠️ Check Your Code

If you use any of these symbols, you need to read this guide:

numpy.maximumnumpy.minimumnp.lib.stride_tricks.strided_window_viewnp.lib.stride_tricks.as_stridednp.ndarraynp.dtypenp.testing.assert_warnsnp.testing.suppress_warningsnumpy.fixnumpy.truncndarray.shapenumpy.reshapenumpy.lib.user_array.containernumpy.linalg.linalgnumpy.fft.helpernumpy.percentilenumpy.nanpercentilenumpy.quantilenumpy.nanquantilenumpy.in1dnumpy.isinnumpy.ndindex.ndincrnumpy.savendarray.ctypes._ctypes.get_datandarray.ctypes._ctypes.get_shapendarray.ctypes._ctypes.get_stridesndarray.ctypes._ctypes.get_as_parameternumpy.trapzdispnumpy.corrcoefnumpy.ma.mrecords.fromtextfilenumpy.array2stringnp.sum

Breaking 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.

Issue #2

Removed numpy.linalg.linalg and numpy.fft.helper.

Solution

Use numpy.linalg instead of numpy.linalg.linalg, and use numpy.fft instead of numpy.fft.helper.

Issue #3

Removed interpolation parameter from quantile and percentile functions (numpy.percentile, numpy.nanpercentile, numpy.quantile, numpy.nanquantile).

Solution

Use the method parameter instead.

Issue #4

numpy.in1d has been removed.

Solution

Use numpy.isin instead.

Issue #5

numpy.ndindex.ndincr() method has been removed.

Solution

Use next(ndindex) instead.

Issue #6

fix_imports parameter has been removed from numpy.save.

Solution

This flag is no longer necessary as it was ignored since NumPy 1.17.

Issue #7

Four undocumented methods of ndarray.ctypes have been removed: _ctypes.get_data(), _ctypes.get_shape(), _ctypes.get_strides(), and _ctypes.get_as_parameter().

Solution

Use _ctypes.data, _ctypes.shape, _ctypes.strides, and _ctypes._as_parameter_ respectively.

Issue #8

newshape parameter has been removed from numpy.reshape.

Solution

Pass the new shape positionally or use shape= keyword argument.

Issue #9

numpy.trapz has been removed.

Solution

Use numpy.trapezoid or scipy.integrate functions instead.

Issue #10

disp function has been removed.

Solution

Use your own printing function instead.

Issue #11

bias and ddof arguments in numpy.corrcoef have been removed (they had no effect since NumPy 1.10).

Solution

Remove these arguments.

Issue #12

delimitor parameter has been removed from numpy.ma.mrecords.fromtextfile().

Solution

Use delimiter instead.

Issue #13

style parameter has been removed from numpy.array2string. Any arguments following it are now keyword-only.

Solution

Remove the style argument. Ensure subsequent arguments are passed as keywords.

Issue #14

Calling np.sum(generator) directly on a generator object now raises TypeError.

Solution

Use np.sum(np.fromiter(generator)) or the python sum builtin instead.

Migration Steps

  1. 1
    If you were setting array strides directly, 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.
  2. 2
    Update calls to np.maximum and np.minimum to use the keyword argument for the output array: out=c.
  3. 3
    Ensure align= is explicitly passed as a boolean keyword argument when calling np.dtype().
  4. 4
    Replace usage of np.testing.assert_warns and np.testing.suppress_warnings with standard Python warnings module functions or pytest equivalents.
  5. 5
    Replace calls to np.fix with np.trunc.
  6. 6
    Replace direct assignment to ndarray.shape with calls to np.reshape.
  7. 7
    If using numpy.linalg.linalg or numpy.fft.helper, update imports to use numpy.linalg or numpy.fft directly.
  8. 8
    If using percentile/quantile functions, replace the interpolation parameter with the method parameter.
  9. 9
    Replace calls to np.in1d with np.isin.
  10. 10
    Replace calls to ndindex.ndincr() with next(ndindex).
  11. 11
    Replace calls to np.trapz with np.trapezoid or scipy.integrate functions.
  12. 12
    Replace calls to numpy.ma.mrecords.fromtextfile() using delimitor with delimiter.
  13. 13
    Remove the style parameter from np.array2string and ensure subsequent arguments are passed as keywords.
  14. 14
    Wrap generator objects passed to np.sum() with np.fromiter() or use the built-in sum().

Release Summary

NumPy 2.4.0 introduces improvements for free threaded Python support, user dtypes, and annotations, alongside removing many long-deprecated APIs and finalizing prior deprecations.

Need More Details?

View the full release notes and all changes for NumPy v2.4.0.

View Full Changelog