Hi all, I’m trying to use python’s @decorator syntax to more easily create TF1 objects from python functions. It’s not working like I expect, but maybe it’s because I don’t understand decorators enough.
Here is what I normally do to create a TF1 from a python function:
def f(x): return x class f_from_TF1: def __call__(self,x): return f(x) start,end = 0,1 nparams = 0 f_TF1 = ROOT.TF1(f.func_name,f_from_TF1(),start,end,nparams)
Since this is pretty generic, to avoid writing the code over and over again, I wish to have a @TF1ify decorator that could work like this:
@TF1ify(start,end,params) def f(x): return x
Does anyone already have one of these? Seems like it might be useful, if there is a good version existing, could it somehow be included in PyROOT?