Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix numpy API deprecations np.trapz -> np.trapezoid #81

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mflike/mflike.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def logp(self, **params_values):
return self.loglike(cl, **params_values_nocosmo)

def loglike(self, cl, **params_values_nocosmo):
"""
r"""
Computes the gaussian log-likelihood

:param cl: the dictionary of theory + foregrounds :math:`D_{\ell}`
Expand Down
17 changes: 12 additions & 5 deletions mflike/theoryforge.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
from itertools import product

import numpy as np
if np.__version__ >= "2.0.0":
from numpy import trapezoid as trapz
else:
from numpy import trapz

from cobaya.log import LoggedError


Expand Down Expand Up @@ -214,7 +219,7 @@ def _bandpass_construction(self, **params):
tranb = _cmb2bb(nub)
# normalization integral to be evaluated at the shifted freqs
# in order to have cmb component calibrated to 1
tranb_norm = np.trapz(_cmb2bb(nub), nub)
tranb_norm = trapz(_cmb2bb(nub), nub)
self.bandint_freqs.append([nub, tranb / tranb_norm])
# in case we don't want to do band integration, e.g. when we have multifreq bandpass in sacc file
if self.bandint_nsteps == 1:
Expand All @@ -229,7 +234,7 @@ def _bandpass_construction(self, **params):
data_are_monofreq = True
self.bandint_freqs.append(nub[0])
else:
trans_norm = np.trapz(bp * _cmb2bb(nub), nub)
trans_norm = trapz(bp * _cmb2bb(nub), nub)
trans = bp / trans_norm * _cmb2bb(nub)
self.bandint_freqs.append([nub, trans])

Expand Down Expand Up @@ -336,15 +341,17 @@ def _init_foreground_model(self):
self.ksz = fgc.FactorizedCrossSpectrum(fgf.ConstantSED(), fgp.kSZ_bat())
self.cibp = fgc.FactorizedCrossSpectrum(fgf.ModifiedBlackBody(), fgp.PowerLaw())
self.radio = fgc.FactorizedCrossSpectrum(fgf.PowerLaw(), fgp.PowerLaw())
self.tsz = fgc.FactorizedCrossSpectrum(fgf.ThermalSZ(), fgp.PowerLawRescaledTemplate(tsz_file))
self.tsz = fgc.FactorizedCrossSpectrum(
fgf.ThermalSZ(), fgp.PowerLawRescaledTemplate(tsz_file)
)
self.cibc = fgc.FactorizedCrossSpectrum(fgf.CIB(), fgp.PowerSpectrumFromFile(cibc_file))
self.dust = fgc.FactorizedCrossSpectrum(fgf.ModifiedBlackBody(), fgp.PowerLaw())

tsz_cib_sed = fgf.Join(fgf.ThermalSZ(), fgf.CIB())
tsz_cib_power_spectra = [
fgp.PowerLawRescaledTemplate(tsz_file),
fgp.PowerSpectrumFromFile(cibc_file),
fgp.PowerSpectrumFromFile(cibxtsz_file)
fgp.PowerSpectrumFromFile(cibxtsz_file),
]
tsz_cib_cl = fgp.PowerSpectraAndCovariance(*tsz_cib_power_spectra)

Expand Down Expand Up @@ -439,7 +446,7 @@ def _get_foreground_model(self, ell=None, freqs_order=None, **fg_params):
"ell": ell,
"ell_0": ell_0,
"amp": fg_params["a_tSZ"],
"alpha": fg_params["alpha_tSZ"]
"alpha": fg_params["alpha_tSZ"],
},
{"ell": ell, "ell_0": ell_0, "amp": fg_params["a_c"]},
{
Expand Down