Skip to content
Snippets Groups Projects
Commit eb06dc2e authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Fix two minor issues in dynesty printed output

1. Flush the output: neccersery when writing to file
2. Write the total ellapsed time of the run rather than the time since
the last checkpoint
parent c14eb63b
No related branches found
No related tags found
1 merge request!1036Fix two minor issues in dynesty printed output
Pipeline #305497 passed
......@@ -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()
......
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