diff --git a/bilby/core/sampler/cpnest.py b/bilby/core/sampler/cpnest.py index 27122cdf8dda1257fd35be4d2dd27741671af08e..0ac52c7ba1454d5c39949c03afc767842d6e9844 100644 --- a/bilby/core/sampler/cpnest.py +++ b/bilby/core/sampler/cpnest.py @@ -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): diff --git a/test/sampler_test.py b/test/sampler_test.py index 88bfc4a04b15c77fb39b95fe8a45d2c0c6d922c2..e937a6452d25e4df75162aab7301caafc4951ea8 100644 --- a/test/sampler_test.py +++ b/test/sampler_test.py @@ -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']