Open tBuLi opened 4 years ago
In principle, I agree so long as the current syntax remains available. Also, proper type checking is required (are the keys to data
really Variables
?). Leftover edge cases would be mixing the new data
keyword (keyword only?) and the existing syntax.
data = {x: xdata, y: ydata, Cov(x, y): xycovariance}
I like this idea, augmented with Stdev
and Var
. Var
would create a Variable
if given a string, and otherwise does nothing. We should very explicitly not create a Parameter
analogue since these shorthands should only be used to create data
dicts, and parameters have no place in those. I'd like some further debate on the name of Stdev
. An alternative could be Sigma
? StdErr
? StdDev
?
data = {x: xdata, y:ydata, model.sigmas[(x,y)]: xycovariance, model.sigmas[y]: yerr}
This is very very ugly. I veto this.
The global fitting example you give looks quite OK. I'm not super happy with how to create the Parameters
and Variables
, but that's not for this issue.
Introduction
The data API to
Fit
has some drawbacks that need to be addressed. Firstly, the use of*args,**kwargs
to send data is not a good design when large amount of variables need to be provided with data. Secondly, the possible names forVariable
's are more constrained insymfit
then in puresympy
. Thirdly, the result is cast into a dict with variables as keys and data as values.Therefore, it seems like a better idea to use such a dict in the first place:
For the basics I think this is a very clean API, but there are some more advanced features which should be supported:
Covariances
For co-variances, a possible API would be
where
Cov
could be a new symbol subclass or a convenience method which returns a new variable encoding this information. Similar objects could then be made forStdev
andVar
.Another option would be to use and expand the
.sigmas
dict already present on model classes:such that we could write
Global fitting
A global fitting problem will be written using indexed variables in the future:
where
x
andy
use the two different allowable styles of providing data to indexed variables. This can be combined with either of the afore mentioned API covariance styles.