autoemx.core.fitter.fast_model_eval module
Faster evaluation of lmfit composite models.
The spectrum model is a CompositeModel with many components (one per X-ray peak plus the background factors). On every evaluation, lmfit’s Model.make_funcargs rebuilds the arguments of each component by scanning all parameters, which dominates the cost of a model evaluation.
FastCompositeModel builds the mapping from parameters to each component’s function arguments once per set of parameter names, following the same precedence rules as Model.make_funcargs, and then evaluates the same component functions, combined with the same operators. Results are therefore identical to CompositeModel.eval.
- Main Class:
FastCompositeModel: CompositeModel with cached argument mapping in eval()
- class autoemx.core.fitter.fast_model_eval.FastCompositeModel(left, right, op, **kws)[source]
Bases:
CompositeModelCompositeModel whose eval() reuses a precomputed parameter-to-argument mapping.
Only eval() is changed. eval_components(), components, param_names and fitting behave as in CompositeModel. Calls that lmfit handles specially (keyword arguments overriding parameter values, or params not given as a Parameters object) fall back to CompositeModel.eval.