Commit 58d60aa7 authored by Gregory Ashton's avatar Gregory Ashton

Fix bug in corner plot and hyper PE example

- Fixes bug when setting truths
- Remove mu=None, sigma=None in hyper PE example
parent 1d4772b1
Pipeline #19895 passed with stages
in 13 minutes and 11 seconds
......@@ -68,7 +68,7 @@ run_prior = tupak.prior.Uniform(minimum=-10, maximum=10, name='mu_m')
hyper_prior = tupak.prior.Gaussian(mu=0, sigma=1, name='hyper')
hp_likelihood = tupak.likelihood.HyperparameterLikelihood(
samples, hyper_prior, run_prior, mu=None, sigma=None)
samples, hyper_prior, run_prior)
hp_priors = dict(
mu=tupak.prior.Uniform(-10, 10, 'mu', '$\mu_m$'),
......
......@@ -122,37 +122,32 @@ class Result(dict):
bins=50, smooth=0.9, label_kwargs=dict(fontsize=16),
title_kwargs=dict(fontsize=16), color='#0072C1',
truth_color='tab:orange', show_titles=True,
quantiles=[0.025, 0.975], levels=(0.39,0.8,0.97),
quantiles=[0.025, 0.975], levels=(0.39, 0.8, 0.97),
plot_density=False, plot_datapoints=True, fill_contours=True,
max_n_ticks=3)
defaults_kwargs.update(kwargs)
kwargs = defaults_kwargs
if 'truth' in kwargs:
kwargs['truths'] = kwargs.pop('truth')
if getattr(self, 'injection_parameters', None) is not None:
injection_parameters = [self.injection_parameters[key]
for key in self.search_parameter_keys]
kwargs['truth'] = kwargs.get('truth', injection_parameters)
kwargs['truths'] = kwargs.get('truths', injection_parameters)
if type(kwargs.get('truth')) == dict:
old_keys = kwargs['truth'].keys()
new_keys = self.get_latex_labels_from_parameter_keys(old_keys)
for old, new in zip(old_keys, new_keys):
kwargs['truth'][new] = kwargs['truth'].pop(old)
if parameters is None:
parameters = self.search_parameter_keys
if 'truth' in kwargs:
kwargs['truths'] = kwargs.pop('truth')
xs = self.posterior[parameters].values
kwargs['labels'] = kwargs.get(
'labels', self.get_latex_labels_from_parameter_keys(
parameters))
if parameters:
xs = self.posterior[parameters].values
kwargs['labels'] = kwargs.get(
'labels', self.get_latex_labels_from_parameter_keys(
parameters))
else:
xs = self.posterior[self.search_parameter_keys]
kwargs['labels'] = kwargs.get(
'labels', self.get_latex_labels_from_parameter_keys(
self.search_parameter_keys))
if type(kwargs.get('truths')) == dict:
truths = [kwargs['truths'][k] for k in parameters]
kwargs['truths'] = truths
fig = corner.corner(xs, **kwargs)
......
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