Skip to content

Commit

Permalink
Merge pull request #36 from ckoerber/multi-model-api
Browse files Browse the repository at this point in the history
Multi model api
  • Loading branch information
ckoerber authored Nov 5, 2021
2 parents 1ca8856 + 6490767 commit d4dbfe4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lsqfitgui/backend/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion lsqfitgui/util/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d4dbfe4

Please sign in to comment.