Hi, I have a C++ class MyInterpolator that inherits from ROOT::Math::Interpolator.
One of the things I do is overload the Eval and Deriv methods to accept the signature “Double_t Eval(Double_t * x, Double_t *) const” so that I can feed the MyInterpolator into a TF1 constructor. The base class method has the signature Eval(double x).
In a CINT terminal, I can do the following:
* ROOT v5.34/18 *
root [0] .L t2x.C+
root [1] t2x::MyInterpolator * inter = t2x::t2xer(12,0)
root [2] inter->Eval(0.2)
(const double)5.03465017533624382e-01
root [3] Double_t x[] = {0.2}
root [4] inter->Eval(x,0)
(const Double_t)5.03465017533624382e-01
root [5] inter->Eval( // Tab-complete to show signatures
Double_t Eval(Double_t* x, Double_t*) const
So it looks like CINT automatically knows about base class methods when they are called, but it doesn’t show them when you tab-complete.
In PyROOT, when I try to do the same thing, I get this:
In [1]: import ROOT,array
In [2]: ROOT.gROOT.ProcessLine(".L t2x.C+")
Out[2]: 0L
In [3]: inter = ROOT.t2x.t2xer(12,0)
In [4]: x = array.array('d',[0.2])
In [5]: inter.Eval(x,ROOT.nullptr)
Out[5]: 0.5034650175336244
In [6]: inter.Eval(0.2)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-c25abf27dfa4> in <module>()
----> 1 inter.Eval(0.2)
TypeError: Double_t MyInterpolator::Eval(Double_t* x, Double_t*) =>
takes at least 2 arguments (1 given)
In [7]: help(inter.Eval)
Eval(self, Double_t* x, Double_t*) method of __main__.t2x::MyInterpolator instance
Double_t MyInterpolator::Eval(Double_t* x, Double_t*)
I know I can manually overload/hide the Eval(double x) method in my derived class and just make it call the base class method with the same signature, but I am wondering if there is some automated way to make PyROOT aware of base class methods? In my case, I only need one or two methods for the class, but I could imagine that for a big class (say a derived version of TH1) doing it for all the methods would be very tedious.
Jean-François