Commit d1e73544 authored by Theo Steininger's avatar Theo Steininger

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

Moved list-structure of prior and likelihood from the sum_likelihood.py and sum_prior.py 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):
@likelihood.setter
def likelihood(self, likelihood):
if not isinstance(likelihood, Likelihood):
raise TypeError(
"likelihood must be an instance of Likelihood-class.")
self.logger.debug("Setting likelihood.")
self._likelihood = likelihood
self._likelihood = ()
for l in likelihood:
if not isinstance(l, Likelihood):
raise TypeError(
"likelihood must be an instance of Likelihood-class.")
self._likelihood += (l,)
@property
def prior(self):
......@@ -60,11 +61,13 @@ class Pipeline(Loggable, object):
@prior.setter
def prior(self, prior):
if not isinstance(prior, Prior):
raise TypeError(
"prior must be an instance of Prior-class.")
self.logger.debug("Setting prior.")
self._prior = prior
self._prior = ()
for p in prior:
if not isinstance(p, Prior):
raise TypeError(
"prior must be an instance of Prior-class.")
self._prior += (p,)
@property
def magnetic_field_factory(self):
......@@ -109,4 +112,4 @@ class Pipeline(Loggable, object):
self._ensemble_size = ensemble_size
def __call__(self, variables):
pass
\ No newline at end of file
pass
# -*- 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
Markdown is supported
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