python - class method as a model function for scipy.optimize.curve_fit -
there statement in manual of curve_fit
the model function, f(x, ...). must take independent variable first argument , parameters fit separate remaining arguments.
however, use model function method of class defined as:
def model_fun(self,x,par):
so, first argument not independent variable, can see. there way how can use method of class model function curve_fit
sure, create instance , pass bound method:
class myclass(object): ... def model_fun(self,x,par): ... obj = myclass(...) curve_fit(obj.model_fun, ...)
you can find explanation bound/unbound/etc. in this question.
Comments
Post a Comment