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

Minor bug fixing

parent 5b4355b9
No related branches found
No related tags found
1 merge request!423Improvements to checkpointing for emcee/ptemcee
Pipeline #56015 passed
......@@ -274,6 +274,8 @@ class Emcee(MCMCSampler):
if hasattr(self, '_sampler'):
pass
elif self.resume and os.path.isfile(self.checkpoint_info.sampler_file):
logger.info("Resuming run from checkpoint file {}"
.format(self.checkpoint_info.sampler_file))
with open(self.checkpoint_info.sampler_file, 'rb') as f:
self._sampler = pickle.load(f)
self._set_pos0_for_resume()
......@@ -335,13 +337,14 @@ class Emcee(MCMCSampler):
iterations = sampler_function_kwargs.pop('iterations')
iterations -= self._previous_iterations
print('pos0', self.pos0)
sampler_function_kwargs['p0'] = self.pos0
# main iteration loop
for sample in tqdm(
self.sampler.sample(iterations=iterations, **sampler_function_kwargs),
total=iterations):
self.write_chains_to_file(sample)
self.checkpoint()
self.result.sampler_output = np.nan
blobs_flat = np.array(self.sampler.blobs).reshape((-1, 2))
......
......@@ -42,7 +42,7 @@ class Ptemcee(Emcee):
label=label, use_ratio=use_ratio, plot=plot,
skip_import_verification=skip_import_verification,
nburn=nburn, burn_in_fraction=burn_in_fraction,
burn_in_act=burn_in_act, resume=True, **kwargs)
burn_in_act=burn_in_act, resume=resume, **kwargs)
@property
def sampler_function_kwargs(self):
......@@ -116,6 +116,7 @@ class Ptemcee(Emcee):
**sampler_function_kwargs),
total=iterations):
self.write_chains_to_file(pos, loglike, logpost)
self.checkpoint()
self.calculate_autocorrelation(self.sampler.chain.reshape((-1, self.ndim)))
self.result.sampler_output = np.nan
......
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