Commit d1e73544 authored by Theo Steininger's avatar Theo Steininger
Browse files

Moved list-structure of prior and likelihood from the and...

Moved list-structure of prior and likelihood from the and into the pipeline.
parent deeb7d7e
# -*- coding: utf-8 -*-
from likelihood import Likelihood
class SumLikelihood(Likelihood):
def __init__(self, likelihoods):
self.likelihoods = []
for likelihood in likelihoods:
assert isinstance(likelihood, Likelihood)
self.likelihoods += [likelihood]
def __call__(self, observables):
likelihood = 0
for current_likelihood in self.likelihoods:
likelihood += current_likelihood(observables)
return likelihood
......@@ -47,12 +47,13 @@ class Pipeline(Loggable, object):
def likelihood(self, likelihood):
if not isinstance(likelihood, Likelihood):
self.logger.debug("Setting likelihood.")
self._likelihood = ()
for l in likelihood:
if not isinstance(l, Likelihood):
raise TypeError(
"likelihood must be an instance of Likelihood-class.")
self.logger.debug("Setting likelihood.")
self._likelihood = likelihood
self._likelihood += (l,)
def prior(self):
......@@ -60,11 +61,13 @@ class Pipeline(Loggable, object):
def prior(self, prior):
if not isinstance(prior, Prior):
self.logger.debug("Setting prior.")
self._prior = ()
for p in prior:
if not isinstance(p, Prior):
raise TypeError(
"prior must be an instance of Prior-class.")
self.logger.debug("Setting prior.")
self._prior = prior
self._prior += (p,)
def magnetic_field_factory(self):
# -*- coding: utf-8 -*-
from prior import Prior
class SumPrior(Prior):
def __init__(self, priors):
self.priors = []
for prior in priors:
assert isinstance(prior, Prior)
self.priors += [prior]
def __call__(self, parameters):
prior = 0
for current_prior in self.priors:
prior += current_prior(parameters)
return prior
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment