Skip to content

Commit

Permalink
Merge pull request #164 from joezuntz/maxlike-save-block
Browse files Browse the repository at this point in the history
Add output_block option to maxlike sampler
  • Loading branch information
joezuntz authored Jan 13, 2025
2 parents 4acbff7 + fb501cb commit 8a407f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cosmosis/samplers/maxlike/maxlike_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def config(self):
self.maxiter = self.read_ini("maxiter", int, 1000)
self.output_ini = self.read_ini("output_ini", str, "")
self.output_cov = self.read_ini("output_covmat", str, "")
self.output_block = self.read_ini("output_block", str, "")
self.method = self.read_ini("method",str,"Nelder-Mead")
self.max_posterior = self.read_ini("max_posterior", bool, False)
self.repeats = self.read_ini("repeats", int, 1)
Expand Down Expand Up @@ -114,6 +115,9 @@ def save_final_outputs(self, best_fit_results, final=False):

if self.output_ini:
self.pipeline.create_ini(results.vector, self.output_ini)

if self.output_block:
results.block.save_to_directory(self.output_block)


# We only want to update the distribution hints at the very end
Expand Down
4 changes: 3 additions & 1 deletion cosmosis/test/test_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ def test_maxlike():
with tempfile.TemporaryDirectory() as dirname:
output_ini = os.path.join(dirname, "output.ini")
output_cov = os.path.join(dirname, "output_cov.txt")
run('maxlike', True, can_postprocess=False, method="L-BFGS-B", max_posterior=True, output_ini=output_ini, output_covmat=output_cov)
output_block = os.path.join(dirname, "output_block")
run('maxlike', True, can_postprocess=False, method="L-BFGS-B", max_posterior=True, output_ini=output_ini, output_covmat=output_cov, output_block=output_block)
assert os.path.exists(output_cov)
assert os.path.exists(output_ini)
assert os.path.isdir(output_block)



Expand Down

0 comments on commit 8a407f8

Please sign in to comment.