Roel,
On Tue, 31 Jan 2012 15:45:01 +0100, Roel Aaij <Roel.Aaij_at_cern.ch> wrote:
> Hi,
>
> The LHCb software framework uses Reflex dictionaries to provide python
> bindings for most of its C++ classes. To be able to interact with one
> of the C++ classes from python, I need to be able to create a
> std::map<std::string, double>. A dictionary for this type exists, but
> it does not allow me to do the following:
>
> >>> import ROOT
> >>> m = ROOT.std.map('string', 'double')()
> >>> p = ROOT.std.pair('string', 'double')('one', 1.)
> >>> m.insert(p)
>
> The full error message is included at the bottom. It seems that a
> dictionary is not being picked up for the return type of the insert
> method, while I believe I have created it as a Reflex dictionary (log
> of genreflex is attached).
>
> For a similar type, std::map<unsigned long, bool>, generating
> appropriate dictionaries for the map, pair<const unsigned long, bool>,
> iterators and the return type of map.insert allows me to perform the
> same operation. Since the map<string, double> dictionary seems to be a
> Cint dictionary, I suspect that cooperation between Cint dictionaries
> and Reflex dictionaries has a problem here. Perhaps the types are
> slightly differently defined?
>
> Any ideas on what is going wrong?
for reflex dictionaries to be available from CINT and PyROOT, one needs to enable Cintex:
import PyCintex
PyCintex.Cintex.Enable()
*before* opening any ROOT file (as this might load up and/or generate CINT dictionaries as side-effects)
I have the following helper function:
def import_root(batch=True):
"""a helper method to wrap the 'import ROOT' statement to prevent ROOT from messing up the display or loading graphics libraries when in batch mode (which is the default.)
e.g.
>>> ROOT = import_root(batch=True)
>>> f = ROOT.TFile.Open(...)
"""
import ROOT
ROOT.gROOT.SetBatch(batch)
if batch:
ROOT.PyConfig.IgnoreCommandLineOptions = True
import PyCintex
PyCintex.Cintex.Enable()
return ROOT
hth,
-s
-- ######################################### # Dr. Sebastien Binet # Laboratoire de l'Accelerateur Lineaire # Universite Paris-Sud XI # Batiment 200 # 91898 Orsay #########################################Received on Tue Jan 31 2012 - 16:05:34 CET
- application/pgp-signature attachment: stored
This archive was generated by hypermail 2.2.0 : Tue Jan 31 2012 - 17:50:01 CET