diff --git a/bilby/core/sampler/dynesty.py b/bilby/core/sampler/dynesty.py index 11197d1ed8dc4c2c9796f8bf684027b6f84b1f2e..ebc0f3d451c5c3b778c821864939488b7b94c961 100644 --- a/bilby/core/sampler/dynesty.py +++ b/bilby/core/sampler/dynesty.py @@ -35,10 +35,15 @@ class Dynesty(NestedSampler): Stopping criteria verbose: Bool If true, print information information about the convergence during + check_point: bool, + If true, use check pointing. check_point_delta_t: float (600) The approximate checkpoint period (in seconds). Should the run be interrupted, it can be resumed from the last checkpoint. Set to `None` to turn-off check pointing + n_check_point: int, optional (None) + The number of steps to take before check pointing (override + check_point_delta_t). resume: bool If true, resume run from checkpoint (if available) """ @@ -58,21 +63,20 @@ class Dynesty(NestedSampler): save_bounds=True) def __init__(self, likelihood, priors, outdir='outdir', label='label', use_ratio=False, plot=False, - skip_import_verification=False, n_check_point=None, check_point_delta_t=600, + skip_import_verification=False, check_point=True, n_check_point=None, check_point_delta_t=600, resume=True, **kwargs): NestedSampler.__init__(self, likelihood=likelihood, priors=priors, outdir=outdir, label=label, use_ratio=use_ratio, plot=plot, skip_import_verification=skip_import_verification, **kwargs) self.n_check_point = n_check_point + self.check_point = check_point self.resume = resume - if not self.n_check_point: - # Set the checking pointing - # If the log_likelihood_eval_time was not able to be calculated - # then n_check_point is set to None (no checkpointing) + if self.n_check_point is None: + # If the log_likelihood_eval_time is not calculable then + # check_point is set to False. if np.isnan(self._log_likelihood_eval_time): - self.n_check_point = None - # If n_check_point is not already set, set it checkpoint every 10 mins + self.check_point = False n_check_point_raw = (check_point_delta_t / self._log_likelihood_eval_time) n_check_point_rnd = int(float("{:1.0g}".format(n_check_point_raw))) self.n_check_point = n_check_point_rnd @@ -148,7 +152,7 @@ class Dynesty(NestedSampler): prior_transform=self.prior_transform, ndim=self.ndim, **self.sampler_init_kwargs) - if self.n_check_point: + if self.check_point: out = self._run_external_sampler_with_checkpointing() else: out = self._run_external_sampler_without_checkpointing()