Commit 529f1988 authored by Gregory Ashton's avatar Gregory Ashton

Adds basic functionality for adding posterior sample sets together

parent 82a23f1c
Pipeline #24199 passed with stages
in 2 minutes and 13 seconds
......@@ -73,6 +73,15 @@ class Result(dict):
val = self._standardise_a_string(dictionary[key])
setattr(self, key, val)
def __add__(self, other):
if other.sampler != self.sampler:
raise ValueError(
"Unable to add results generated from different samplers")
self.samples = np.concatenate([self.samples, other.samples])
self.posterior = pd.concat([self.posterior, other.posterior])
return self
def __dir__(self):
""" Adds tab completion in ipython
......@@ -99,13 +108,13 @@ class Result(dict):
"log_noise_evidence: {:6.3f}\n"
"log_evidence: {:6.3f} +/- {:6.3f}\n"
"log_bayes_factor: {:6.3f} +/- {:6.3f}\n"
.format(len(self.samples), self.log_noise_evidence, self.log_evidence,
.format(len(self.posterior), self.log_noise_evidence, self.log_evidence,
self.log_evidence_err, self.log_bayes_factor,
self.log_evidence_err))
else:
return ("nsamples: {:d}\n"
"log_evidence: {:6.3f} +/- {:6.3f}\n"
.format(len(self.samples), self.log_evidence, self.log_evidence_err))
.format(len(self.posterior), self.log_evidence, self.log_evidence_err))
else:
return ''
......
......@@ -187,6 +187,7 @@ class Sampler(object):
"""
result = Result()
result.sampler = self.__class__.__name__.lower()
result.search_parameter_keys = self.__search_parameter_keys
result.fixed_parameter_keys = self.__fixed_parameter_keys
result.parameter_labels = [
......
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