Skip to content
Snippets Groups Projects
Commit ee24e35b authored by Sylvia Biscoveanu's avatar Sylvia Biscoveanu Committed by Gregory Ashton
Browse files

cpnest checkpointing

parent cd57498b
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ class Cpnest(NestedSampler):
"""
default_kwargs = dict(verbose=1, nthreads=1, nlive=500, maxmcmc=1000,
seed=None, poolsize=100, nhamiltonian=0, resume=True,
output=None, proposals=None, n_periodic_checkpoint=None)
output=None, proposals=None, n_periodic_checkpoint=8000)
def _translate_kwargs(self, kwargs):
if 'nlive' not in kwargs:
......@@ -120,7 +120,8 @@ class Cpnest(NestedSampler):
def _verify_kwargs_against_default_kwargs(self):
"""
Set the directory where the output will be written.
Set the directory where the output will be written
and check resume and checkpoint status.
"""
if not self.kwargs['output']:
self.kwargs['output'] = \
......@@ -128,6 +129,8 @@ class Cpnest(NestedSampler):
if self.kwargs['output'].endswith('/') is False:
self.kwargs['output'] = '{}/'.format(self.kwargs['output'])
check_directory_exists_and_if_not_mkdir(self.kwargs['output'])
if self.kwargs['n_periodic_checkpoint'] and not self.kwargs['resume']:
self.kwargs['n_periodic_checkpoint'] = None
NestedSampler._verify_kwargs_against_default_kwargs(self)
def _resolve_proposal_functions(self):
......
......@@ -113,14 +113,14 @@ class TestCPNest(unittest.TestCase):
expected = dict(verbose=1, nthreads=1, nlive=500, maxmcmc=1000,
seed=None, poolsize=100, nhamiltonian=0, resume=True,
output='outdir/cpnest_label/', proposals=None,
n_periodic_checkpoint=None)
n_periodic_checkpoint=8000)
self.assertDictEqual(expected, self.sampler.kwargs)
def test_translate_kwargs(self):
expected = dict(verbose=1, nthreads=1, nlive=250, maxmcmc=1000,
seed=None, poolsize=100, nhamiltonian=0, resume=True,
output='outdir/cpnest_label/', proposals=None,
n_periodic_checkpoint=None)
n_periodic_checkpoint=8000)
for equiv in bilby.core.sampler.base_sampler.NestedSampler.npoints_equiv_kwargs:
new_kwargs = self.sampler.kwargs.copy()
del new_kwargs['nlive']
......
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