I cannot seem to be able to assign items in vector objects in PyROOT. The following simple example shows this:
from ROOT import *
test=std.vector('bool')()
test.push_back(True)
test[0]=False
The last command returns error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'vector<bool,allocator<bool> >' object does not support item assignment
I found a thread from 2010 (en.it-usenet.org/thread/14263/1675/) reporting the exact same error, with the same problem occurring in CINT. However that was fixed and I don’t see a problem with CINT.
I have this problem with ROOT/Python versions 5.34.08/2.7.5 (from Gentoo Linux) and 5.30.02/2.6.5 (from ATLAS software thing).
I think it’s related to the fact that vector is a “special” kind of std::vector which has different interfaces. It packs the boolean values for smaller storage, but when you access elements, it doesn’t happen directly. I don’t know much more than this, but here is some reading: