Home | News | Documentation | Download

Ways to work around the redefinition of compiled functions in one single Notebook session?

I’m working with PyROOT on a Notebook environment. Let’s say I’ve created a function and compiled it with ROOT.Numba, e.g. entering something below in a code cell:

import ROOT
@ROOT.Numba.Declare(['float', 'int'], 'float')
def myfunc(x, y):
    return x**y

Very often, the function is not yet final. I may need to modify it several more times.

However, when I try to re-run the code cell, I would get a redefinition error like below:

input_line_686:5:20: error: redefinition of 'myfunc'
float myfunc(float x, int y) {

I understand that this behavior is totally expected because the Notebook is still in the same Python session, meaning that it “remembers” the declared functions. So unless I restart the kernel every time I modify the numba function, which is really time-consuming, I couldn’t really find a workaround for this matter.

My question: Is there a way to “delete” the functions compiled with ROOT.Numba? Thanks.

**Simiarly, when declaring variables/functions using ROOT.gInterpreter.Declare(), similar issue of redefinition will happen. I have tried doing gROOT.Reset() and realized that didn’t quite help.


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22.02
Platform: Linux Debian 8
Compiler: gcc 4.9.2


@etejedor Can you help?