exa.core.model_selection_fitter.models.model_utils.prefix_expr

Contents

exa.core.model_selection_fitter.models.model_utils.prefix_expr#

prefix_expr(model, expr)#

The expression with every parameter of model it names carrying the model prefix.

lmfit prefixes the parameters a model owns but not the names inside the expressions its hints carry, so an expression written in bare names refers to nothing once the model has a prefix. Rewriting it here keeps one spelling of the expression working for every prefix.

Used directly where a prefixed expression is needed outside of set_param_hint, such as post_fit adding a parameter to an already-fitted Parameters object. Everywhere a hint is set, prefer decorating set_param_hint with prefixed_expr() instead.

Parameters:
  • model (Model) – Model whose prefix and parameter names the expression is rewritten for.

  • expr (str) – Expression in bare (prefix-free) parameter names.

Returns:

The expression with the model prefix on each name that is a parameter of the model, and every other name, such as a function or a constant, left as it was.

Return type:

str