Example pyroot004_NumbaDeclare.py throws exception

Hello all,

I’m trying to run the PyROOT Numba tutorial example but it seems to throw an exception, shown below [1]. I’ve tried both my local ROOT (6.25/01) and the SWAN version 6.24/06, and get the same error. Any clues what might be going on? Here’s the link to the example:

https://root.cern/doc/master/pyroot004__NumbaDeclare_8py.html

Thank you,
Andre

[1]


AttributeError Traceback (most recent call last)
/cvmfs/sft.cern.ch/lcg/views/LCG_101swan/x86_64-centos7-gcc8-opt/lib/ROOT/_numbadeclare.py in get_inner_type(t)
52 try:
—> 53 g = re.match(’(.)<(.)>’, t).groups(0)
54 return g[1]

AttributeError: ‘NoneType’ object has no attribute ‘groups’

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)
/tmp/ipykernel_516/1282498792.py in
1 @ROOT.Numba.Declare([‘RVecF’, ‘int’], ‘RVecF’)
----> 2 def pypowarray(x, y):
3 return x**y
4
5 ROOT.gInterpreter.ProcessLine(’’’

/cvmfs/sft.cern.ch/lcg/views/LCG_101swan/x86_64-centos7-gcc8-opt/lib/ROOT/_numbadeclare.py in inner(func, input_types, return_type, name)
125
126 # Jit the given Python callable with numba
→ 127 nb_return_type, nb_input_types = get_numba_signature(input_types, return_type)
128 try:
129 nbjit = nb.jit(nb_return_type(*nb_input_types), nopython=True, inline=‘always’)(func)

/cvmfs/sft.cern.ch/lcg/views/LCG_101swan/x86_64-centos7-gcc8-opt/lib/ROOT/_numbadeclare.py in get_numba_signature(input_types, return_type)
110 for t in input_types:
111 if ‘RVec’ in t:
→ 112 nb_input_types.append(get_numba_type(get_inner_type(t))[:])
113 else:
114 nb_input_types.append(get_numba_type(t))

/cvmfs/sft.cern.ch/lcg/views/LCG_101swan/x86_64-centos7-gcc8-opt/lib/ROOT/_numbadeclare.py in get_inner_type(t)
54 return g[1]
55 except:
—> 56 raise Exception(‘Failed to extract template argument of type {}’.format(t))
57
58 def get_numba_type(t):

Exception: Failed to extract template argument of type RVecF


ROOT Version: 6.24/06 (SWAN LCG 101), 6.25/01 (local)
Platform: CentOS 7 (SWAN), MacOS 12.1 (local)
Compiler: gcc8 (SWAN), clang 12.0.5 (local)


You need to use the versions of the tutorials appropriate for your ROOT versions, e.g., for ROOT 6.24: pyroot004_NumbaDeclare.py

Ah, thanks very much! I did not realize the examples vary by ROOT version, but thinking about it it makes sense of course.

Andre

Though does this mean that the examples in the master documentation don’t always work if there are breaking changes? Ideally a user should always go to the version of the documentation that they are using, but it’s easy to forget :slight_smile:

Hi,

Newer versions of the examples might use newer features and modern patterns that were not available in older ROOT versions, I don’t think we can do much there.

The other way round should be fine: using older versions of the tutorials with newer versions of ROOT should be OK as we try hard not to break existing APIs. The exception is the occasional deprecation of some interfaces, bit that’s a rare occurrence.

Cheers,
Enrico

1 Like