SciPy deprecation warning for scipy.integrate.cumtrapz
Closed this issue · 4 comments
When calculating with the Beam
, SciPy 1.12 raises DeprecationWarning
:
DeprecationWarning: 'scipy.integrate.cumtrapz' is deprecated in favour of 'scipy.integrate.cumulative_trapezoid' and will be removed in SciPy 1.14.0
Therefore, we need to replace deprecated cumtrapz()
with the cumulative_trapezoid()
in SingeRayAttenuator._beam_attenuation()
. However, the new name was only introduced in SciPy 1.7, and the tests fail in the Python 3.7 + oldest-supported-numpy environment.
I suggest using:
try:
from scipy.integrate import cumulative_trapezoid
except ImportError:
from scipy.integrate import cumtrapz as cumulative_trapezoid
I am getting an ImportError with Scipy 1.14:
File /usr/local/lib/python3.10/dist-packages/cherab/core/model/attenuator/init.py:1
from .singleray import SingleRayAttenuator
File /usr/local/lib/python3.10/dist-packages/cherab/core/model/attenuator/singleray.pyx:21, in init cherab.core.model.attenuator.singleray()
ImportError: cannot import name cumtrapz
I tried adding
try:
from scipy.integrate import cumulative_trapezoid
except ImportError:
from scipy.integrate import cumtrapz as cumulative_trapezoid
to the file singleray.pyx
instead of the from scipy.integrate import cumtrapz
but it still gave the same error after that. I am not too familiar with how the C and Python interacts (if this problem even relates to that) so I would appreciate some help.