Bonjour
I’ve a question about dictionary generation and the library auto-loading done with ROOT when dealing with python interface. I’m so far amazed by how simple that is (thanks a lot for that) and would like to know whether I might be doing something wrong in my mwe.
I’m defining new classes within nested namespace, all inheriting from ROOT and I’ve realised that if I have several namespace I cannot access by autocompletion the content of the underlying objects.
In order to be a but clearer, I’ve created a mwe only defining a poinless class (taken out of your documentation actually ) and I’ll use it either in single namespace level or a two namespace one.
In the attached tarball you’ll find the twoints.(cpp/hpp) that define the TwoInts class with a preprocessor argument (-DTWOLEVELS) that states that there will be two nested namespace (CHOCOLAT::JBB: instead of one (only JBB::).
Once ROOT is setup and I’m doing
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
make single
I’m producing a libJBB.so, libJBB.rootmap and libJBB_rdict.pcm which allow me to get this in the python console
from ROOT import JBB
dir(JBB)[‘TwoInts’,
‘add’,
‘bool’,
‘class’,
‘delattr’,
‘destruct’,
‘dict’,
‘dir’,
‘dispatch’,
‘doc’,
‘eq’,
‘format’,
‘ge’,
‘getattribute’,
‘gt’,
‘hash’,
‘init’,
‘init_subclass’,
‘invert’,
‘le’,
‘lt’,
‘module’,
‘mul’,
‘ne’,
‘neg’,
‘new’,
‘pos’,
‘python_owns’,
‘radd’,
‘reduce’,
‘reduce_ex’,
‘repr’,
‘rmul’,
‘rsub’,
‘rtruediv’,
‘setattr’,
‘sizeof’,
‘smartptr’,
‘str’,
‘sub’,
‘subclasshook’,
‘truediv’,
‘weakref’]
It’s nice to see that I can see the class TwoInts from here and so from the auto-completion approach as well.
now changing the compilation to get two levels of namespace (CHOCOLAT::JBB) by doing this
make double
I can see this kind of results once in python
from ROOT import CHOCOLAT
dir(CHOCOLAT.JBB)[‘add’,
‘bool’,
‘class’,
‘delattr’,
‘destruct’,
‘dict’,
‘dir’,
‘dispatch’,
‘doc’,
‘eq’,
‘format’,
‘ge’,
‘getattribute’,
‘gt’,
‘hash’,
‘init’,
‘init_subclass’,
‘invert’,
‘le’,
‘lt’,
‘module’,
‘mul’,
‘ne’,
‘neg’,
‘new’,
‘pos’,
‘python_owns’,
‘radd’,
‘reduce’,
‘reduce_ex’,
‘repr’,
‘rmul’,
‘rsub’,
‘rtruediv’,
‘setattr’,
‘sizeof’,
‘smartptr’,
‘str’,
‘sub’,
‘subclasshook’,
‘truediv’,
‘weakref’]
Do you have any idea why the TwoInts class is not shown anymore ?
It is working anyway, as once I’m typing this, I have no problem
p=CHOCOLAT.JBB.TwoInts(1,2)
p.GetA(), p.GetB()(1, 2)
To be fair it’s all working smoothly, but it would be even nicer if all classes were to be seen disregarding the number of namespace. It might come from my LinkDef configuration as well, I haven’t find an example like mine so far.
Thanks in advance
cheers
jb
RootExample.tar.gz (903 Bytes)
ROOT Version: 6.26.00
Platform: fedora 32
Compiler: 10.0.1