From 33a782cc6b65d3df54175b2596e2c05fa77da4c4 Mon Sep 17 00:00:00 2001 From: Joe Zuntz Date: Mon, 9 Dec 2024 08:44:07 +0000 Subject: [PATCH] expose bobyqa hessian --- cosmosis/samplers/maxlike/maxlike_sampler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cosmosis/samplers/maxlike/maxlike_sampler.py b/cosmosis/samplers/maxlike/maxlike_sampler.py index a8d1290c..d11754d9 100755 --- a/cosmosis/samplers/maxlike/maxlike_sampler.py +++ b/cosmosis/samplers/maxlike/maxlike_sampler.py @@ -144,6 +144,10 @@ def run_optimizer(self, inputs): } optimizer_result = pybobyqa.solve(likefn, start_vector, **kw) opt_norm = optimizer_result.x + # bobyqa calls it .hessian but scipy calls it .hess, so copy it here + # if available + if optimizer_result.hessian is not None: + optimizer_result.hess = optimizer_result.hessian else: # Use scipy mainimizer instead optimizer_result = scipy.optimize.minimize(likefn, start_vector, method=self.method,