From 1a89e8e8cb4b6dbe2cb4c517398c2af27459c84f Mon Sep 17 00:00:00 2001
From: Colm Talbot <colm.talbot@ligo.org>
Date: Mon, 26 Feb 2024 19:36:59 +0000
Subject: [PATCH] MAINT: switch to cumulative_trapezoid

---
 bilby/core/prior/base.py         | 4 ++--
 bilby/core/prior/interpolated.py | 4 ++--
 bilby/gw/eos/eos.py              | 4 ++--
 bilby/gw/prior.py                | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/bilby/core/prior/base.py b/bilby/core/prior/base.py
index 4ac924f74..0dcac2c0a 100644
--- a/bilby/core/prior/base.py
+++ b/bilby/core/prior/base.py
@@ -168,14 +168,14 @@ class Prior(object):
 
     def cdf(self, val):
         """ Generic method to calculate CDF, can be overwritten in subclass """
-        from scipy.integrate import cumtrapz
+        from scipy.integrate import cumulative_trapezoid
         if np.any(np.isinf([self.minimum, self.maximum])):
             raise ValueError(
                 "Unable to use the generic CDF calculation for priors with"
                 "infinite support")
         x = np.linspace(self.minimum, self.maximum, 1000)
         pdf = self.prob(x)
-        cdf = cumtrapz(pdf, x, initial=0)
+        cdf = cumulative_trapezoid(pdf, x, initial=0)
         interp = interp1d(x, cdf, assume_sorted=True, bounds_error=False,
                           fill_value=(0, 1))
         return interp(val)
diff --git a/bilby/core/prior/interpolated.py b/bilby/core/prior/interpolated.py
index 187e8a60a..2cee669d9 100644
--- a/bilby/core/prior/interpolated.py
+++ b/bilby/core/prior/interpolated.py
@@ -162,11 +162,11 @@ class Interped(Prior):
         self._initialize_attributes()
 
     def _initialize_attributes(self):
-        from scipy.integrate import cumtrapz
+        from scipy.integrate import cumulative_trapezoid
         if np.trapz(self._yy, self.xx) != 1:
             logger.debug('Supplied PDF for {} is not normalised, normalising.'.format(self.name))
         self._yy /= np.trapz(self._yy, self.xx)
-        self.YY = cumtrapz(self._yy, self.xx, initial=0)
+        self.YY = cumulative_trapezoid(self._yy, self.xx, initial=0)
         # Need last element of cumulative distribution to be exactly one.
         self.YY[-1] = 1
         self.probability_density = interp1d(x=self.xx, y=self._yy, bounds_error=False, fill_value=0)
diff --git a/bilby/gw/eos/eos.py b/bilby/gw/eos/eos.py
index ca7799ebb..2e962aa0c 100644
--- a/bilby/gw/eos/eos.py
+++ b/bilby/gw/eos/eos.py
@@ -55,7 +55,7 @@ class TabularEOS(object):
     """
 
     def __init__(self, eos, sampling_flag=False, warning_flag=False):
-        from scipy.integrate import cumtrapz
+        from scipy.integrate import cumulative_trapezoid
 
         self.sampling_flag = sampling_flag
         self.warning_flag = warning_flag
@@ -83,7 +83,7 @@ class TabularEOS(object):
             self.warning_flag = True
         else:
             integrand = self.pressure / (self.energy_density + self.pressure)
-            self.pseudo_enthalpy = cumtrapz(integrand, np.log(self.pressure), initial=0) + integrand[0]
+            self.pseudo_enthalpy = cumulative_trapezoid(integrand, np.log(self.pressure), initial=0) + integrand[0]
 
             self.interp_energy_density_from_pressure = CubicSpline(np.log10(self.pressure),
                                                                    np.log10(self.energy_density),
diff --git a/bilby/gw/prior.py b/bilby/gw/prior.py
index 63b51790e..81dd2d557 100644
--- a/bilby/gw/prior.py
+++ b/bilby/gw/prior.py
@@ -1385,10 +1385,10 @@ class HealPixMapPriorDist(BaseJointPriorDist):
         """
         Method that builds the inverse cdf of the P(pixel) distribution for rescaling
         """
-        from scipy.integrate import cumtrapz
+        from scipy.integrate import cumulative_trapezoid
         yy = self._all_interped(self.pix_xx)
         yy /= np.trapz(yy, self.pix_xx)
-        YY = cumtrapz(yy, self.pix_xx, initial=0)
+        YY = cumulative_trapezoid(yy, self.pix_xx, initial=0)
         YY[-1] = 1
         self.inverse_cdf = interp1d(x=YY, y=self.pix_xx, bounds_error=True)
 
-- 
GitLab