My question is how to make a map of vectors of strings in pyroot. I am accessing C++ code that produces a std::map<std::string,std::vectorstd::string> .
I’ve tried just using a dictionary of lists but that does not work.
I know there is syntax like ROOT.std.map(“string,whatever”) but I can’t see how to tell it how to make the more complicated object of nested stl thingies.
So the simple question is - how do I make x = std::map<std::string,std::vectorstd::string> in pyroot.
Thanks, Heidi - ok, I’ve been using root for over 20 years but I only get to code on vacations so I’m always rusty.
ROOT Version: 6.16 Platform: mac running Mojave
_Compiler:
gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.20.17)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
you are looking in the right direction with ROOT.std.map, but for complicated types I would do it on the C++ - side with ROOT.gInterpreter.Declare or ProcessLine.
@etejedor probably knows the pythonic way, but I guess we have to wait for next week when people are coming back from vacation.
Ok, so I made a C++ function that creates a map of vectors of the objects I want. I can ginterpret it to load, make it, I can put stuff in it but then when I try to call a C++ constructor for HistWrapper with it as an argument I get the following
I suppose that the ROOT.map is a python object with C++ map attached such that the thing can be handled from the python side. Without a code example, I don’t see what’s going on, but tomorrow, @etejedor should be able to have a look.