Hello Wim,
Here is the result of dir().
>>> dir(test.b)
['__add__', '__assign__', '__class__', '__delattr__', '__dict__', '__div__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__nonzero__', '__radd__', '__rdiv__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__rsub__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__weakref__', 'assign', 'begin', 'capacity', 'clear', 'empty', 'end', 'erase', 'insert', 'max_size', 'pop_back', 'push_back', 'rbegin', 'rend', 'reserve', 'resize', 'size', 'swap', 'vector']
>>> dir(test.d)
['__add__', '__assign__', '__class__', '__delattr__', '__dict__', '__div__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__nonzero__', '__radd__', '__rdiv__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__rsub__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__weakref__', '_vector__at', 'at', 'back', 'begin', 'capacity', 'clear', 'empty', 'end', 'erase', 'front', 'insert', 'max_size', 'pop_back', 'push_back', 'rbegin', 'rend', 'reserve', 'resize', 'size', 'swap', 'vector']
As you can see above, a part of vector's method can be accessed from python. For example, test.b.size() returns 3L as expected.
'__getitem__', '__setitem__', '_vector__at', 'at', 'back', 'front' are missing in vector<Bool_t> but it has 'assign' method instead.
I found that this is not a limitation by PyROOT but CINT itself has this problem. Below is the minimum code to produce this.
root [0] #include <vector> root [1] std::vector<Bool_t> v(3, 0) root [2] v[0]
I get the same result on both OS X 10.6 and Scientific Linux 5 with ROOT 5.27.02.
Regards,
-- OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu} Institute of Space and Astronautical Science (ISAS/JAXA) Now at KIPAC/SLAC/Stanford Varian Physics #306 382 Via Pueblo Mall, MC 406 Stanford, CA94305 TEL 650-736-0971/FAX 650-724-5065 Skype : okumura.akira On 2010/06/28, at 21:11, WLavrijsen_at_lbl.gov wrote:Received on Tue Jun 29 2010 - 06:37:46 CEST
> Akira,
>
>> File "test.py", line 27, in <module> >> print b[i] >> TypeError: 'vector<bool,allocator<bool> >' object does not support indexing
>
> typically means that there's no dictionary loaded for said vector class. Have
> a look at the results of dir(b) and see whether it has the normal methods.
>
> Best regards,
> Wim
> --
> WLavrijsen_at_lbl.gov -- +1 (510) 486 6411 -- www.lavrijsen.net
This archive was generated by hypermail 2.2.0 : Tue Jun 29 2010 - 11:50:01 CEST