Commit 0276a77a authored by Gregory Ashton's avatar Gregory Ashton

Merge branch 'nestle-classic-sampling' into 'master'

Allow nestle "classic" sampling mode

Closes #310

See merge request lscsoft/bilby!533
parents 940383f8 b6c375bf
Pipeline #72254 failed with stages
in 17 minutes and 51 seconds
......@@ -525,6 +525,7 @@ class Sampler(object):
class NestedSampler(Sampler):
npoints_equiv_kwargs = ['nlive', 'nlives', 'n_live_points', 'npoints', 'npoint', 'Nlive']
walks_equiv_kwargs = ['walks', 'steps', 'nmcmc']
def reorder_loglikelihoods(self, unsorted_loglikelihoods, unsorted_samples,
sorted_samples):
......
......@@ -149,6 +149,10 @@ class Dynesty(NestedSampler):
if 'print_progress' not in kwargs:
if 'verbose' in kwargs:
kwargs['print_progress'] = kwargs.pop('verbose')
if 'walks' not in kwargs:
for equiv in self.walks_equiv_kwargs:
if equiv in kwargs:
kwargs['walks'] = kwargs.pop(equiv)
def _verify_kwargs_against_default_kwargs(self):
if not self.kwargs['walks']:
......
......@@ -29,13 +29,17 @@ class Nestle(NestedSampler):
default_kwargs = dict(verbose=True, method='multi', npoints=500,
update_interval=None, npdim=None, maxiter=None,
maxcall=None, dlogz=None, decline_factor=None,
rstate=None, callback=None)
rstate=None, callback=None, steps=20, enlarge=1.2)
def _translate_kwargs(self, kwargs):
if 'npoints' not in kwargs:
for equiv in self.npoints_equiv_kwargs:
if equiv in kwargs:
kwargs['npoints'] = kwargs.pop(equiv)
if 'steps' not in kwargs:
for equiv in self.walks_equiv_kwargs:
if equiv in kwargs:
kwargs['steps'] = kwargs.pop(equiv)
def _verify_kwargs_against_default_kwargs(self):
if self.kwargs['verbose']:
......
......@@ -240,14 +240,14 @@ class TestNestle(unittest.TestCase):
expected = dict(verbose=False, method='multi', npoints=500,
update_interval=None, npdim=None, maxiter=None,
maxcall=None, dlogz=None, decline_factor=None,
rstate=None, callback=None)
rstate=None, callback=None, steps=20, enlarge=1.2)
self.assertDictEqual(expected, self.sampler.kwargs)
def test_translate_kwargs(self):
expected = dict(verbose=False, method='multi', npoints=345,
update_interval=None, npdim=None, maxiter=None,
maxcall=None, dlogz=None, decline_factor=None,
rstate=None, callback=None)
rstate=None, callback=None, steps=20, enlarge=1.2)
self.sampler.kwargs['npoints'] = 123
for equiv in bilby.core.sampler.base_sampler.NestedSampler.npoints_equiv_kwargs:
new_kwargs = self.sampler.kwargs.copy()
......
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