symfit
symfit copied to clipboard
Provide data to Fit as dict instead
Perhaps a good improvement on our syntax would be to provide data to Fit
as a dict instead:
model = Model({y: a * x + b})
fit = Fit(model, data={x: xdata, y: ydata})
This would have multiple advantages:
- no more naming conflict, e.g. you could have both a Matrix and a Variable with the same name. (Why would you want to, but still)
- Derivatives are then valid and we can do away with their name generation:
model = Model({D(y, x): a * x + b})
fit = Fit(model, data={x: xdata, D(y, x): ydata})
Since behind the screens we do this anyway, it might be worth considering bringing this up front.
To criticize my own idea: this will not play nice with code generation, dummy names will still have to be generated then in case of conflicts. But sympy
can already do this in fact by setting dummify=True
when printing..