A lmfit Model takes a model function provided by the user and constructs a curve-fitting minimization for that model function. It creates named Parameter objects based on the names of the function arguments of the model function. Model will also identify independent variables that are not variables in the fit but are expected to be passed in to help the calculation of the curve-fitting Model. Typically (but not always), there is one of these, and by default (but can be changed) the first function argument will be expected to be "the independent variable". Typically (so, again, not always) the independent variable will be an array of the same length as the data to be modeled.
Arguments for the model function that have default values that are not numeric (None, bool, string, etc) are also not turned into variable Parameters.
Other function arguments to the model function are interpreted as variables and will be made into Parameter objects (so, float64 scalar values).
Variable Parameters must be names, so using `*args` or `**kws` in the Model function do not get mapped to Parameters.
You might be able to get away with something like
(similar to what we do for PolynomialModel): ```
def poly(x, c0=0, c1=0, c2=0, c3=0, c4=0, c5=0, c6=0, c7=0):
return np.polyval([c7, c6, c5, c4, c3, c2, c1, c0], x)
model = Model(poly)
params = model.make_params(c0=1, c1=3, c2=5)
for pname in ('c3', 'c4', c5', 'c6', 'c7'):
params[pname].vary = False
```
With this, you would have a polynomial with 3 variables, and the other arguments having the default value of 0 that will not vary in the fit. It is easy to go up to 7 variables (and easy to modify to go to 10, if that is what you want).
That sort of approach is necessary if you want to use Model. If you don't use Model, but use `minimize` instead, then you write an objective function, which returns the array to be minimized (so, typically 'data-model'). In that approach, the objective function takes one Parameters object (so, "arbitrarily sized", at least in principle) as the first argument and any other arguments you might want to pass in for the calculation (say, data `x` and `y` arrays), and then your objective function handles the unpacking and using of the items in the Parameters dictionary.
Which approach you want to use might be different for your example script and the real-world use case. The Objective function approach is more flexible, but might be a little more work to get started.