From f6ee05e31a9081b596324f906d93b9356f808450 Mon Sep 17 00:00:00 2001 From: Christopher Koerber Date: Fri, 5 Nov 2021 09:11:35 +0100 Subject: [PATCH] Set models attribute on meta and prior changes --- lsqfitgui/backend/sidebar.py | 8 +++++++- lsqfitgui/util/models.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lsqfitgui/backend/sidebar.py b/lsqfitgui/backend/sidebar.py index b588dd7..5224a5f 100644 --- a/lsqfitgui/backend/sidebar.py +++ b/lsqfitgui/backend/sidebar.py @@ -24,7 +24,13 @@ def process_priors(prior_flat, initial_fit): else: prior[key] = gv.gvar(prior_flat[f"{key}-mean"], prior_flat[f"{key}-sdev"]) - return nonlinear_fit(initial_fit.data, initial_fit.fcn, prior) + fit = nonlinear_fit(initial_fit.data, initial_fit.fcn, prior) + + for attr in ["models", "meta"]: + if hasattr(initial_fit, attr): + setattr(fit, attr, getattr(initial_fit, attr)) + + return fit def process_meta(meta_array, meta_config): diff --git a/lsqfitgui/util/models.py b/lsqfitgui/util/models.py index 3c91335..9ec409b 100644 --- a/lsqfitgui/util/models.py +++ b/lsqfitgui/util/models.py @@ -21,7 +21,10 @@ def lsqfit_from_multi_model_fit( def fcn(x, p): return {m.datatag: m.fitfcn(m.buildprior(p)) for m in models} - return nonlinear_fit((x_data, y_data), fcn=fcn, prior=prior) + fit = nonlinear_fit((x_data, y_data), fcn=fcn, prior=prior) + fit.models = models + + return fit def lsqfit_from_multi_model_fit_wrapper(fcn):