symfit icon indicating copy to clipboard operation
symfit copied to clipboard

Provide data to Fit as dict instead

Open tBuLi opened this issue 5 years ago • 1 comments

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.

tBuLi avatar Jun 18 '19 16:06 tBuLi

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..

tBuLi avatar Jun 18 '19 16:06 tBuLi