Skip to content

Commit

Permalink
Merge pull request #437 from vsnever/fix/cumtrapz_deprecation
Browse files Browse the repository at this point in the history
Fix SciPy cumtrapz deprecation warning
  • Loading branch information
jacklovell authored May 16, 2024
2 parents 058d26c + 858ad98 commit f0a43f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cherab/core/model/attenuator/singleray.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from scipy.integrate import cumtrapz
try:
from scipy.integrate import cumulative_trapezoid
except ImportError:
from scipy.integrate import cumtrapz as cumulative_trapezoid

import numpy as np
cimport numpy as np

Expand Down Expand Up @@ -257,7 +261,7 @@ cdef class SingleRayAttenuator(BeamAttenuator):
for i in range(naxis):
stopping_coeff[i] = self._beam_stopping(x[i], y[i], z[i], beam_velocity)

return beam_density * np.exp(-cumtrapz(stopping_coeff, axis, initial=0.0) / speed)
return beam_density * np.exp(-cumulative_trapezoid(stopping_coeff, axis, initial=0) / speed)

@cython.cdivision(True)
cdef double _beam_stopping(self, double x, double y, double z, Vector3D beam_velocity):
Expand Down

0 comments on commit f0a43f2

Please sign in to comment.