Context:
I am implementing a particle physics library called LCIO that is C++ code, but there is a python wrapper called pyLCIO.
When trying to run a function called setMomentum()
the C++ implementation looks like this:
void setMomentum (const float p[3])
Simple float array.
Alright python, lets try this:
particle.setMomentum([1.0,2.0,3.0])
The problem:
Now this threw an error. Here is the traceback:
Traceback (most recent call last):
File "driver.py", line 5, in <module>
particle.setMomentum(momentum)
File "/path/to/pyLCIO/base/HandleExceptions.py", line 17, in wrappedMethod
return method(*args, **kargs)
TypeError: none of the 2 overloaded methods succeeded. Full details:
void MCParticleImpl::setMomentum(const float* p) =>
could not convert argument 1
void MCParticleImpl::setMomentum(const double* p) =>
could not convert argument 1
Now this function is asking for a #1 constant, #2 the reference to the head of the array. How am I supposed to do this with python?
Does anyone with exerience with python wrapped C++ code, know how to creade a const float*
in python?
Thank you for any help.
EDIT 180314
I tried:
particle.setMomentum((1.0,2.0,3.0))
To no avail; same error.