Skip to content
Snippets Groups Projects
Commit 9bdb9e14 authored by Colm Talbot's avatar Colm Talbot
Browse files

Merge branch 'add-method-to-convert-to-delta-functions' into 'master'

Adds explicit method to convert floats to delta functions

See merge request Monash/tupak!80
parents 884abf92 89852a39
No related branches found
No related tags found
1 merge request!80Adds explicit method to convert floats to delta functions
Pipeline #
......@@ -65,6 +65,20 @@ class PriorSet(dict):
prior[key] = eval(val)
self.update(prior)
def convert_floats_to_delta_functions(self):
""" Convert all float parameters to delta functions """
for key in self:
if isinstance(self[key], Prior):
continue
elif isinstance(self[key], float) or isinstance(self[key], int):
self[key] = DeltaFunction(self[key])
logging.debug(
"{} converted to delta function prior.".format(key))
else:
logging.debug(
"{} cannot be converted to delta function prior."
.format(key))
def fill_priors(self, likelihood, default_priors_file=None):
"""
Fill dictionary of priors based on required parameters of likelihood
......@@ -91,17 +105,7 @@ class PriorSet(dict):
"""
for key in self:
if isinstance(self[key], Prior):
continue
elif isinstance(self[key], float) or isinstance(self[key], int):
self[key] = DeltaFunction(self[key])
logging.debug(
"{} converted to delta function prior.".format(key))
else:
logging.debug(
"{} cannot be converted to delta function prior."
.format(key))
self.convert_floats_to_delta_functions()
missing_keys = set(likelihood.parameters) - set(self.keys())
......@@ -138,6 +142,7 @@ class PriorSet(dict):
-------
dict: Dictionary of the samples
"""
self.convert_floats_to_delta_functions()
samples = dict()
for key in self:
if isinstance(self[key], Prior):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment