Const double *something

Maybe someone had already treated this issue, but I’m new and with a quick search I don’t’ find nothing related… So, sorry if I’m a repeater…

I’ve found that PyROOT has problem to understand this kind of variables in the classes. Practical example:

a = TAxis(3, [1., 2., 3.])

or

b = [1., 2., 3.]
a = TAxis(3, b)

he doesn’t recognize the second argument as an array (that in C++ is declared as “const double *something”).
Someone knows how to give an array as argument in this case?

Thanks to everyone…
Alessio

Try giving as an argument a numpy array (for example numpy.array([1,2,3])).

Ok, it works… Thank you!!!

Hi,

yes, the C++ side expects an array as a contiguous piece of memory. A python list is a list of pointers to python objects that wrap those doubles. An array from python module array would work as well. For numpy, make sure that the array is flat.

Cheers,
Wim

Interesting… I’ve discovered python few months ago and I don’t now yet everything (especially such things).

At this point I’ve a question, but I’m going to ask in another tread ([url]SetFcn

Thanks for everything…