Home | News | Documentation | Download

Error calling Migrad in python

I am getting the following error:

TypeError: int TMinuit::Migrad() =>
    TypeError: callable was deleted

when calling:

import ROOT
gMinuit = ROOT.TMinuit(10)
# setup the function, etc...
gMinuit.Migrad()

This is with Root 6.22, and worked fine with Root 6.18 and previously for many years.

_ROOT Version: 6.22
_Platform: Mac (MacPorts)
Compiler: Not Provided


Hi @roodman,

Could you please send us a minimal code excerpt that we can use to reproduce the problem? Other than that, I am sure @moneta can help with this.

Cheers.

Hello,
I would recommend not to use TMinuit, but the ROOT::Math::Minimizer class. It should work fine in Python. A C++ example is here: ROOT: tutorials/fit/NumericalMinimization.C File Reference

Lorenzo

Thanks for the responses - with further searching around this forum, I found the issue. As of Root 6.22 the types of the arguments in a TMinuit FCN function changed from TROOT types to python ctypes.

I had:

def chisq(self,npar, gin, f, par, iflag ):
    ... calculate stuff
    f[0] = chisquared

but this needs to change to:

    f.value = chisquared

Aaron