From 921caa77a751a0d9a432f115fd71c1164cf72e8f Mon Sep 17 00:00:00 2001 From: Joe Zuntz Date: Fri, 26 Jul 2024 10:37:28 +0100 Subject: [PATCH] Change pocomc.Prior object to use a global Pipeline variabkle --- cosmosis/samplers/poco/poco_sampler.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cosmosis/samplers/poco/poco_sampler.py b/cosmosis/samplers/poco/poco_sampler.py index d521ea72..1dd5b5ec 100755 --- a/cosmosis/samplers/poco/poco_sampler.py +++ b/cosmosis/samplers/poco/poco_sampler.py @@ -10,16 +10,15 @@ def log_likelihood(p): class Prior: - def __init__(self, pipeline): - self.pipeline = pipeline - self.dim = len(self.pipeline.varied_params) - self.bounds = np.array([p.limits for p in self.pipeline.varied_params]) + def __init__(self): + self.dim = len(pipeline.varied_params) + self.bounds = np.array([p.limits for p in pipeline.varied_params]) def logpdf(self, x): - return np.array([self.pipeline.prior(p) for p in x]) + return np.array([pipeline.prior(p) for p in x]) def rvs(self, size=None): - return np.array([self.pipeline.randomized_start() for i in range(size)]) + return np.array([pipeline.randomized_start() for i in range(size)]) class PocoMCSampler(ParallelSampler): @@ -73,7 +72,7 @@ def config(self): # Finally we can create the sampler self.sampler = self.pocomc.Sampler( - prior=Prior(self.pipeline), + prior=Prior(), likelihood=log_likelihood, random_state=seed, n_effective=self.n_effective,