diff --git a/bilby/core/sampler/dynesty.py b/bilby/core/sampler/dynesty.py index 8dea52a9b21bc9ab6aa8ae89dcb30fe14b4d4919..154866becde66a1438b9f35606b97d566cecffa8 100644 --- a/bilby/core/sampler/dynesty.py +++ b/bilby/core/sampler/dynesty.py @@ -246,6 +246,12 @@ class Dynesty(NestedSampler): else: self._last_print_time = _time + # Add time in current run to overall sampling time + total_time = self.sampling_time + _time - self.start_time + + # Remove fractional seconds + total_time_str = str(total_time).split('.')[0] + # Extract results at the current iteration. (worst, ustar, vstar, loglstar, logvol, logwt, logz, logzvar, h, nc, worst_it, boundidx, bounditer, @@ -281,12 +287,11 @@ class Dynesty(NestedSampler): self.pbar.set_postfix_str(" ".join(string), refresh=False) self.pbar.update(niter - self.pbar.n) elif "interval" in self.kwargs["print_method"]: - formatted = " ".join([str(_time - self.start_time)] + string) - print("{}it [{}]".format(niter, formatted), file=sys.stdout) + formatted = " ".join([total_time_str] + string) + print("{}it [{}]".format(niter, formatted), file=sys.stdout, flush=True) else: - _time = datetime.datetime.now() - formatted = " ".join([str(_time - self.start_time)] + string) - print("{}it [{}]".format(niter, formatted), file=sys.stdout) + formatted = " ".join([total_time_str] + string) + print("{}it [{}]".format(niter, formatted), file=sys.stdout, flush=True) def _apply_dynesty_boundaries(self): self._periodic = list()