Commit 6be834f2 authored by Colm Talbot's avatar Colm Talbot

fix evidence storage and printing when noise evidence is nan

parent 0489e6d4
Pipeline #21522 passed with stages
in 15 minutes and 14 seconds
......@@ -54,13 +54,18 @@ class Result(dict):
def __repr__(self):
"""Print a summary """
if hasattr(self, 'samples'):
return ("nsamples: {:d}\n"
"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,
self.log_evidence_err, self.log_bayes_factor,
self.log_evidence_err))
if hasattr(self, 'log_noise_evidence'):
return ("nsamples: {:d}\n"
"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,
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))
else:
return ''
......
......@@ -574,12 +574,14 @@ def run_sampler(likelihood, priors=None, label='label', outdir='outdir',
else:
result = sampler._run_external_sampler()
result.log_noise_evidence = likelihood.noise_log_likelihood()
if sampler.use_ratio:
result.log_noise_evidence = likelihood.noise_log_likelihood()
result.log_bayes_factor = result.log_evidence
result.log_evidence = result.log_bayes_factor + result.log_noise_evidence
else:
result.log_bayes_factor = result.log_evidence - result.log_noise_evidence
if likelihood.noise_log_likelihood() is not np.nan:
result.log_noise_evidence = likelihood.noise_log_likelihood()
result.log_bayes_factor = result.log_evidence - result.log_noise_evidence
if injection_parameters is not None:
result.injection_parameters = injection_parameters
if conversion_function is not None:
......
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