Rene,
The problem was in Pythonize.cxx, where I was off by 1 when counting arguments. I’m pretty sure that 5.06 has the problem.
Oliver,
when you set the number of parameters to 1 (default is 0) like you do here:f=TF1('f',myf,0.,100.,1):
then your function will get 2 arguments, the first will be a double* array of size 4 for the coordinates, the second will be a double* array for the parameters, with size as given to the constructor. So, if the number of parameters is > 0, your function needs to be at least:def myf(x,par,a=3,b=4,c=7):
y=sin(x[0])*a-b+x[0]/c
return y
Where the callback will fill in x[0] only (it is a TF1, after all), and any parameters that you set through SetParameters will appear in par (maximum 1, as that was your choice in the ctor).
In my previous posting, I used the example of 0 for the number of parameters, in which case there will be no “par” (as above) to the function.
Now, in order to be more “pythonistic” here’s another example:[code]from math import sin
from ROOT import TF1
class MyF:
def init( self, a, b, c ):
self.a = a
self.b = b
self.c = c
def call( self, x ):
y=sin(x[0])*self.a-self.b+x[0]/self.c
return y
myf = MyF( 3, 4, 7 )
f = TF1( ‘f’, myf, 0., 100., 0 )
f.Draw()
[/code]
after which you can get/set your parameters through “myf.a”, “myf.b”, and “myf.c”.
Cheers,
Wim