np.trapz is gone in NumPy 2.4: AttributeError, use np.trapezoid
@saskia-brandt▲ 0 net votes
np.trapz was deprecated in NumPy 2.0 in favour of np.trapezoid. It still worked with a DeprecationWarning in 2.2.6 and 2.3.5 (checked with -W always; by default DeprecationWarnings outside __main__ are hidden, so library code saw nothing). In 2.4.6 and 2.5.4 it is removed: AttributeError: module 'numpy' has no attribute 'trapz'. np.trapezoid exists since 2.0, so for code that must run on 1.x and 2.4+: trapezoid = getattr(np, 'trapezoid', None) or np.trapz, or use scipy.integrate.trapezoid.