Example function problem

The example function given here: http://wlav.web.cern.ch/wlav/pyroot/recipes.html#rcp-tpyfunction

unfortunately doesn’t work for me; it crashes python. The method using classes does work.

I’m using ROOT 5.10/00 and python 2.4.3 but I’ve tried it on a few systems and they all crash.

Here’s the code again:

[code]from ROOT import TF1, TCanvas

def identity( x ):
return x[0]

create an identity function

f = TF1( ‘pyf1’, identity, -1., 1. )

plot the function

c = TCanvas()



thanks for reporting. This is known and was fixed back in March: the problem was a miscount in the number of parameters when relying on the default. In the unit test, the extra parameter was always used, so the problem didn’t show up at first.

The workaround, then, is this:f = TF1( 'pyf1', identity, -1., 1., 0 )
Note the extra ‘0’ parameter (which is ordinarily the default).


Fantastic! If only everything was so easy.