User class pythonisation in recent ROOT releases

Hi all,

The Delphes python analysis code relies on PyROOT’s MakeRootClass() method for the pythonisation of user-defined classes (see https://github.com/delphes/delphes/blob/master/python/DelphesAnalysis/Delphes.py#L30). This method seems have been obsoleted in recent ROOT versions. What is the currently recommended way to perform such pythonisations?

Thanks,

Kerim

Hi @ksuruliz,

The API you are using to add pythonizations is internal to PyROOT (MakeRootClass) and it changed already in ROOT 6.04.

However, you can get the same functionality now by invoking CreateScopeProxy("YourClassName").

Cheers,
Enric

Hi @etejedor,

Thanks, that solved my problem.

Cheers,

Kerim

Hi @ksuruliz,
Glad that helped. I just wanted to add that we are working on supporting pythonizations for user classes via a public API. The idea would be something like:

@pythonization("MyClass")
def pythonizor_method(klass):
    klass.__iter__ = custom_iterator_generator
    ...

That would make it easier for you to add those pythonizations (no need for CreateScopeProxy or similar anymore) and it would make the pythonization lazy: only if you use a given class from your python script, the pythonizations for that class would be applied.

Cheers,
Enric

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