How to implement clone method for the C++ class with some methods overriden in python?

Dear Experts

I am using in PyROOT some (C++) classes with soem method overrided inn python.
e.g. RooAbdPdf with evaluate method implemented in python. Since RooAbsPdf::clone
is called from C++, reimplementation of clone in python is not a well defined task, but I’ve got some workhg ad-hoc solution, not elegant but suitable for my need, see [thiss gitst]
(problme with pythoinns PDF for new ROOT/cppyy · GitHub)

Recenlty, new cppyy/PyROOT (ROOT 6.31/01) enters the game (I am using LCG dev3 cvmfs nightly builds), and, as expeected, my fragile solutuon is not working anymore.
Acrually, the program still works, but it hangs at the exit…

Is there some known/recommended solution for such kind of problems?

Thank you inn advance for any useful hints!

Hi @ibelyaev,

thanks for the report! There is some infinite loop going on, I hope to fix it with this PR:

Indeed, I’m surprised that implementing the clone() method like this even works at all! This is not bad, but indeed a little fragile.

Have you tried implementing a RooAbsPdf class that takes a std::function as an input? Python functions can be implicitly converted to std::function in cppyy. Maybe that is the better was two wrap Python functions in RooFit objects?


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.