-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Avoid needing to type ROOT.ROOT twice in PyROOT #8745
Copy link
Copy link
Closed
Labels
Description
Describe the bug
In PyROOT it has been possible to avoid the double ROOT.ROOT for some classes/functions for a while
import ROOT
df = ROOT.RDataFrameBut that doesn't happen for every new class/function defined in C++ . This is a simple reproducer: create some entities in a namespace:
import ROOT
ROOT.gInterpreter.Declare(
"""
namespace ROOT{
namespace Detail{
struct MyStruct{};
void dostuff(){}
int myint;
}}
"""
)Then try to access them in a Python session
$ python -i namespace_function.py
>>> ROOT.Detail.MyStruct
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: <namespace cppyy.gbl.Detail at 0x55e51fdc7f50> has no attribute 'MyStruct'. Full details:
type object 'Detail' has no attribute 'MyStruct'
'Detail::MyStruct' is not a known C++ class
'MyStruct' is not a known C++ template
'MyStruct' is not a known C++ enum
>>> ROOT.ROOT.Detail.MyStruct
<class cppyy.gbl.ROOT.Detail.MyStruct at 0x55e51fe1dd60>
>>> ROOT.Detail.dostuff
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: <namespace cppyy.gbl.Detail at 0x55e51fdc7f50> has no attribute 'dostuff'. Full details:
type object 'Detail' has no attribute 'dostuff'
'Detail::dostuff' is not a known C++ class
'dostuff' is not a known C++ template
'dostuff' is not a known C++ enum
>>> ROOT.ROOT.Detail.dostuff
<cppyy.CPPOverload object at 0x7f522b684eb0>
>>> ROOT.Detail.myint
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: <namespace cppyy.gbl.Detail at 0x55e51fdc7f50> has no attribute 'myint'. Full details:
type object 'Detail' has no attribute 'myint'
'Detail::myint' is not a known C++ class
'myint' is not a known C++ template
'myint' is not a known C++ enum
>>> ROOT.ROOT.Detail.myint
0It's unclear how to avoid the double ROOT.ROOT in general.
Expected behavior
Be able to avoid typing the name twice, at least for classes/functions defined in ROOT source code.
Setup
ROOT master on Fedora32
Reactions are currently unavailable