lmfit/lmfit-py — pull request #126 by danielballan (2014-09-10 18:13:43+00:00)
Title: Scalars and list

It has always annoyed me that

model.fit([1,2,3], params, x=[1,2,3])

does not do the right thing. In this PR, `fit` interprets Python lists as numpy arrays. Importantly, it does not alter any object that implements the `__array__` interface. This means that it will not transform pandas Series or other unforeseen numpy-like objects. But it will alter generic iterables that don't know how to behave like arrays.

I also caught a bug where we check whether independent vars are scalars.

Finally, I added code to `eval()` to handle the case where models like `ConstantModel` return a scalar. I think that scalar should be broadcast into the shape of the independent variable. (If there is more than one independent variable, users are on their own here.) Notably, this change fixes a bug in `MPLFitter`/`NotebookFitter` that caused plot to raise when the `ConstantModel` was used. It was trying to `plot(x, constant_result)` which is not valid.