Hi all,
I would like to run following code:
[code]import ROOT
from array import array
ROOT.gROOT.Reset()
class MyFun(ROOT.Math.IParametricFunctionMultiDim):
def init(self):
#super(ROOT.Math.IParametricFunctionMultiDim,self).init(self)
self.p = None
print "test = ", self , “; is it null?”
def DoEvalPar(self, x,p):
return 2.*x[0]+p[0]
def NPar(self):
return 1
def NDim(self):
return 2
def Parameters(self):
return self.p
def SetParameters(self,p):
self.p=p
x = array( ‘d’, [ -2.,2.] )
p = array(‘d’,[1.] )
myfun = MyFun()
print myfun(x,p)
fitter = ROOT.Fit.Fitter()
fitdata = ROOT.Fit.BinData(1000,1,ROOT.Fit.BinData.kNoError)
fitdata.Add(0,1)
fitdata.Add(1,2)
fitdata.Add(2,3)
fitter.SetFunction(myfun)
fitter.Fit(fitdata)[/code]
but I get this error:
$ python start.py
test = <ROOT.ROOT::Math::IParametricFunctionMultiDim object at 0x(nil)> ; is it null?
Traceback (most recent call last):
File "start.py", line 32, in <module>
print myfun(x,p)
ReferenceError: attempt to access a null-pointer
So the script stops at line: print myfun(x,p). It seems that there is a problem with proper creation of MyFun class (""object at 0x(nil) "). Moreover, If one tries to call super(ROOT.Math.IParametricFunctionMultiDim,self).init(self) then the output is following:
$ python start.py
Traceback (most recent call last):
File "start.py", line 31, in <module>
myfun = MyFun()
File "start.py", line 8, in __init__
super(ROOT.Math.IParametricFunctionMultiDim,self).__init__(self)
TypeError: IBaseFunctionMultiDim is abstract and can not be instantiated
I guess that it is something “obvious” but i can’t figure out what it is .
What is necessary to do to run this script? What is it the problem?
Cheers,
Jiri
ROOT: 5.26/00b
Python 2.6.5
linux