From f570cc9dbfb3e812a45927eb8c894d94738af35b Mon Sep 17 00:00:00 2001 From: Abhimanyu Susobhanan Date: Mon, 9 Oct 2023 12:28:50 -0500 Subject: [PATCH] faster --- src/pint/fitter.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pint/fitter.py b/src/pint/fitter.py index 4462d6311..f38de0842 100644 --- a/src/pint/fitter.py +++ b/src/pint/fitter.py @@ -1378,20 +1378,19 @@ def _fit_noise(self, noisefit_method="Newton-CG"): xs0 = [getattr(self.model, fp).value for fp in free_noise_params] model1 = copy.deepcopy(self.model) + res = Residuals(self.toas, model1) def _mloglike(xs): """Negative of the log-likelihood function.""" for fp, x in zip(free_noise_params, xs): - getattr(model1, fp).value = x + getattr(res.model, fp).value = x - return -Residuals(self.toas, model1).lnlikelihood() + return -res.lnlikelihood() def _mloglike_grad(xs): """Gradient of the negative of the log-likelihood function w.r.t. white noise parameters.""" for fp, x in zip(free_noise_params, xs): - getattr(model1, fp).value = x - - res = Residuals(self.toas, model1) + getattr(res.model, fp).value = x return np.array( [