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

update to make tests.py run, change internal logic

parent f6be258e
No related branches found
No related tags found
1 merge request!23implement prior generation
Pipeline #
......@@ -314,17 +314,19 @@ def parse_keys_to_parameters(keys):
def fill_priors(prior, waveform_generator, fixed=None):
bad_keys = []
for key in prior:
if isinstance(prior[key], Prior):
continue
elif isinstance(prior[key], float) or isinstance(prior[key], int):
prior[key] = DeltaFunction(prior[key])
print("{} converted to delta function prior.".format(key))
else:
try:
prior[key] = DeltaFunction(prior[key])
print("{} converted to delta function prior.".format(key))
except ValueError:
print("{} cannot be converted to delta function prior.".format(key))
print("If required the default prior will be used.")
prior.pop(key)
print("{} cannot be converted to delta function prior.".format(key))
print("If required the default prior will be used.")
bad_keys.append(key)
for key in bad_keys:
prior.pop(key)
missing_keys = set(waveform_generator.parameters) - set(prior.keys())
......
......@@ -49,10 +49,14 @@ class Test(unittest.TestCase):
likelihood = peyote.likelihood.Likelihood(
[self.msd['IFO']], self.msd['waveform_generator'])
priors = {}
for key in self.msd['simulation_parameters']:
priors[key] = self.msd['simulation_parameters'][key]
# priors.pop('waveform_approximant')
dL = self.msd['simulation_parameters']['luminosity_distance']
priors = {'luminosity_distance' : peyote.prior.Uniform(
priors['luminosity_distance'] = peyote.prior.Uniform(
name='luminosity_distance', lower=dL - 10, upper=dL + 10)
}
result, sampler = peyote.sampler.run_sampler(
likelihood, priors, sampler='nestle', verbose=False)
......
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