2

I have a problem with passing std vector to python.

   std::vector<TMVA::Interval*> parameterRanges;
   parameterRanges.push_back(new TMVA::Interval(-10,10)); 
   parameterRanges.push_back(new TMVA::Interval(0.1,10)); 
   parameterRanges.push_back(new TMVA::Interval(0,2000));

And I have to do that in python. unfortunately I can not change Interval C++ class. I can use std.vector in python, but only std.vector('double') or int, but not object type.

Do you have any idea?

1
  • Can you access TMVA::Interval in Python without putting it in a vector? That would be the problem you would have to solve first. Commented Feb 23, 2015 at 1:06

1 Answer 1

3

As you're using TMVA, I assume you're also having ROOT. There is also a ROOT std::vector wrapper for use in pyroot. It is used as follows:

import ROOT
VectorOfIntervalPointer = ROOT.std.vector('TMVA::Interval*')
# this is only a constructor, not an instance!

instance = VectorOfIntervalPointer()
from ROOT import TMVA.Interval
instance.push_back(TMVA.Interval(-10,10))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.