lmfit-py icon indicating copy to clipboard operation
lmfit-py copied to clipboard

The `prefix` string is not added to parameter names for `CompositeModel`s

Open jcjaskula-aws opened this issue 2 months ago • 3 comments

Description

Strings passed via prefix when constructing a CompositeModel should be propagated to each parameter. Currently, it is missing for direct parameters (e.g. amplitude below) but properly used with derived parameters (like sigma).

A Minimal, Complete, and Verifiable example
from lmfit.models import GaussianModel, ConstantModel
from lmfit.model import CompositeModel
import operator
mm=CompositeModel(GaussianModel(prefix="G_"), ConstantModel(prefix="C_"), operator.add, prefix="prefix_")
mm.make_params()

returns image

mm.prefix returns the string prefix_.

I would expect prefix_G_amplitude, prefix_G_center, prefix_G_sigma, prefix_C_c and the derived parameters to have expressions using the just-mentioned parameters.

Version information

Python: 3.10.14 (main, Mar 19 2024, 21:46:16) [Clang 15.0.0 (clang-1500.3.9.4)]

lmfit: 1.3.1.post0+g3cfd09a1.d20240424, scipy: 1.11.4, numpy: 1.26.3,asteval: 0.9.32, uncertainties: 3.1.6

jcjaskula-aws avatar Apr 24 '24 12:04 jcjaskula-aws