Skip to content

Commit

Permalink
allow older scipy too
Browse files Browse the repository at this point in the history
  • Loading branch information
joezuntz committed Jul 13, 2024
1 parent 250ab7f commit bd0e5fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions number_density/gaussian_window/gaussian_window.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from cosmosis.datablock import option_section
from cosmosis.datablock import names
import numpy as np
import scipy.integrate
try:
from scipy.integrate import trapezoid
except ImportError:
from scipy.integrate import trapz as trapezoid

def setup(options):
z = options[option_section, "z"]
Expand Down Expand Up @@ -43,7 +46,7 @@ def execute(block, config):
nz_bin = gaussian(z, mu[i - 1], sigma[i - 1])
# the bin may not quite go to zero before we get to the
# edges so normalize it
norm = scipy.integrate.trapezoid(nz_bin, z)
norm = trapezoid(nz_bin, z)
nz_bin /= norm
# Save n(z)
block[section, "BIN_%d" % i] = nz_bin
Expand Down
5 changes: 4 additions & 1 deletion number_density/nz_multirank/nz_gz.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

def nz_to_gchi(z, nz, cosmo=cosmology.Planck15):
from numpy import apply_along_axis, gradient, multiply, newaxis
from scipy.integrate import cumulative_trapezoid
try:
from scipy.integrate import cumulative_trapezoid
except ImportError:
from scipy.integrate import cumtrapz as cumulative_trapezoid
chi = cosmo.comoving_distance(z).value
dchi = apply_along_axis(gradient, -1, chi)
dz = apply_along_axis(gradient, -1, z)
Expand Down
5 changes: 4 additions & 1 deletion structure/baccoemu/baccoemu_vendored/matter_powerspectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,10 @@ def _smeared_bao_pk(k_lin=None, pk_lin=None, k_emu=None, pk_lin_emu=None, pk_nw=
:return: smeared BAO pk computed at k_emu
:rtype: array_like
"""
from scipy.integrate import trapezoid
try:
from scipy.integrate import trapezoid
except ImportError:
from scipy.integrate import trapz as trapezoid

if grid is None:
sigma_star_2 = trapezoid(k_lin * pk_lin, x=np.log(k_lin)) / (3 * np.pi**2)
Expand Down

0 comments on commit bd0e5fa

Please sign in to comment.