Hello,

I have one question concerning the conversion from list to array. What I want to do is to have a

list to profit from the append() method without declaring the size of an array beforehand. Then I

want to use the list to fill a TGraph. TGraph takes arrays though so I tried to use scipy.array() for the

conversion but I get the error below. Maybe there is another better way?

What I tried is in the following snippet:

```
#!/usr/bin/env python
import sys
from array import array
from ROOT import *
import scipy
file = TFile("../output/tData.root")
tree=file.Get("mytree")
leaves=tree.GetListOfLeaves()
class PyListOfLeaves(dict) :
pass
pyl = PyListOfLeaves()
#add leaves as attributes
for i in range(0,leaves.GetEntries()):
leaf = leaves.At(i)
name = leaf.GetName()
pyl.__setattr__(name,leaf)
print name
vp=[]
vc=[]
nev = tree.GetEntries()
for iev in range(0,nev):
tree.GetEntry(iev)
p_=pyl.P.GetValue()
print p_
vp.append(p_)
vc.append(iev)
#graphs
g_price_t = TGraph(len(vc),scipy.array(vc),scipy.array(vp))
```

when I run it I get:

Error in sys.excepthook:

Traceback (most recent call last):

File “C:\root\bin\ROOT.py”, line 269, in *excepthook
execfile( fn, main.dict, main.dict )
File “analyzer.py”, line 112, in
g_price_t = TGraph(len(vcount*),scipy.array(vprice_),scipy.array(vcount_))

TypeError: none of the 11 overloaded methods succeeded. Full details:

TGraph::TGraph() =>

takes at most 0 arguments (3 given)

TGraph::TGraph(Int_t n) =>

takes at most 1 arguments (3 given)

TGraph::TGraph(const TGraph& gr) =>

takes at most 1 arguments (3 given)

TGraph::TGraph(const TVectorF& vx, const TVectorF& vy) =>

takes at most 2 arguments (3 given)

TGraph::TGraph(const TVectorD& vx, const TVectorD& vy) =>

takes at most 2 arguments (3 given)

TGraph::TGraph(const TH1* h) =>

takes at most 1 arguments (3 given)

TGraph::TGraph(const TF1* f, Option_t* option = “”) =>

takes at most 2 arguments (3 given)

TGraph::TGraph(const char* filename, const char* format = “%lg %lg”, Option_t*

option = “”) =>

could not convert argument 1 (expected string or Unicode object, int found)

TGraph::TGraph(Int_t n, const Int_t* x, const Int_t* y) =>

could not convert argument 2 (‘numpy.ndarray’ object has no attribute ‘typec

ode’ and given element size (8) do not match needed (4))

TGraph::TGraph(Int_t n, const Float_t* x, const Float_t* y) =>

could not convert argument 2 (‘numpy.ndarray’ object has no attribute ‘typec

ode’ and given element size (8) do not match needed (4))

TGraph::TGraph(Int_t n, const Double_t* x, const Double_t* y) =>

could not convert argument 3 (‘numpy.ndarray’ object has no attribute ‘typec

ode’ and given element size (4) do not match needed (8))

Original exception was:

File “”, line 1

.x analyzer.py

^

SyntaxError: invalid syntax

Any idea? Thanks!

lore