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

More informative message if yp2 not provided #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 18 additions & 13 deletions pyactlike/like.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

# load in cobaya class if it's there
try:
from cobaya.likelihood import Likelihood
from cobaya.likelihoods.base_classes import InstallableLikelihood as Likelihood
from cobaya.tools import are_different_params_lists
from cobaya.log import LoggedError
except:

class Likelihood: # dummy class to inherit if cobaya is missing
Expand Down Expand Up @@ -277,7 +279,7 @@ class ACTPol_lite_DR4(Likelihood):
def initialize(self):
self.components = [c.lower() for c in self.components]
self.packages_path = os.getenv("COBAYA_PACKAGES_PATH", None)
self.calibration_param = ["yp2"]
self.expected_params = ["yp2"]

if not (len(self.components) in (1, 3)):
raise ValueError(
Expand All @@ -293,22 +295,25 @@ def initialize(self):
nbinte=self.nbinte,
nbinee=self.nbinee,
)


def initialize_with_params(self):
# Check that the parameters are the right ones
differences = are_different_params_lists(
self.input_params, self.expected_params,
name_A="given", name_B="expected")
if differences:
raise LoggedError(
self.log, "Configuration error in parameters: %r.",
differences)

def get_requirements(self):
# State requisites to the theory code
self.l_max = self.lmax
return {"yp2": None, "Cl": {cl: self.l_max for cl in self.components}}

def _get_Cl(self):
return self.theory.get_Cl(ell_factor=True)

def _get_theory(self, **params_values):
cl_theory = self._get_Cl()
return cl_theory
return {"yp2": None,"Cl": {cl: self.l_max for cl in self.components}}

def logp(self, **params_values):
Cl = self._get_Cl()
yp2 = self.provider.get_param("yp2")
Cl = self.theory.get_Cl(ell_factor=True)
yp2 = params_values["yp2"]
return self.data.loglike(Cl["tt"][2:], Cl["te"][2:], Cl["ee"][2:], yp2)


Expand Down