Commit ee5ac8fd authored by Moritz's avatar Moritz

Fixed dynesty boundaries and moved some stuff

parent 717db707
Pipeline #56410 passed with stage
in 6 minutes and 14 seconds
......@@ -416,14 +416,6 @@ class Sampler(object):
if use_cache is False:
self.cached_result = None
def _periodic_boundaries_to_binary_list(self, keyword):
self.kwargs[keyword] = []
for param, value in self.priors.items():
if value.periodic_boundary:
self.kwargs[keyword].append(1)
else:
self.kwargs[keyword].append(0)
def _log_summary_for_sampler(self):
"""Print a summary of the sampler used and its kwargs"""
if self.cached_result is None:
......
......@@ -176,7 +176,10 @@ class Dynesty(NestedSampler):
def _apply_dynesty_boundaries(self):
if self.kwargs['periodic'] is None:
self._periodic_boundaries_to_binary_list('periodic')
self.kwargs['periodic'] = []
for i, value in enumerate(self.priors.values()):
if value.periodic_boundary:
self.kwargs['periodic'].append(i)
def run_sampler(self):
import dynesty
......
......@@ -85,7 +85,12 @@ class Pymultinest(NestedSampler):
def _apply_multinest_boundaries(self):
if self.kwargs['wrapped_params'] is None:
self._periodic_boundaries_to_binary_list('wrapped_params')
self.kwargs['wrapped_params'] = []
for param, value in self.priors.items():
if value.periodic_boundary:
self.kwargs['wrapped_params'].append(1)
else:
self.kwargs['wrapped_params'].append(0)
def run_sampler(self):
import pymultinest
......
......@@ -156,7 +156,7 @@ class TestDynesty(unittest.TestCase):
logl_max=np.inf, add_live=True, print_progress=True, save_bounds=True,
walks=10, update_interval=300, print_func='func')
self.sampler.kwargs['print_func'] = 'func' # set this manually as this is not testable otherwise
self.assertListEqual([1, 0], self.sampler.kwargs['periodic']) # Check this separately
self.assertListEqual([0], self.sampler.kwargs['periodic']) # Check this separately
self.sampler.kwargs['periodic'] = None # The dict comparison can't handle lists
for key in self.sampler.kwargs.keys():
print(key)
......@@ -165,7 +165,7 @@ class TestDynesty(unittest.TestCase):
self.assertDictEqual(expected, self.sampler.kwargs)
def test_translate_kwargs(self):
expected = dict(bound='multi', sample='rwalk', periodic=[1, 0], verbose=True,
expected = dict(bound='multi', sample='rwalk', periodic=[0], verbose=True,
check_point_delta_t=600, nlive=250, first_update=None,
npdim=None, rstate=None, queue_size=None, pool=None,
use_pool=None, live_points=None, logl_args=None, logl_kwargs=None,
......@@ -457,8 +457,9 @@ class TestRunningSamplers(unittest.TestCase):
self.likelihood = bilby.likelihood.GaussianLikelihood(
self.x, self.y, self.model, self.sigma)
self.priors = dict(
m=bilby.core.prior.Uniform(0, 5), c=bilby.core.prior.Uniform(-2, 2))
self.priors = bilby.core.prior.PriorDict()
self.priors['m'] = bilby.core.prior.Uniform(0, 5, periodic_boundary=False)
self.priors['c'] = bilby.core.prior.Uniform(-2, 2, periodic_boundary=False)
bilby.core.utils.check_directory_exists_and_if_not_mkdir('outdir')
def tearDown(self):
......
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