I am trying a pass a vector of doubles that I generate in my C++
code to a python
numpy array. I am looking to do some downstream processing in P
_import_array(); //this is required for numpy to create an array correctly
Note: In Numpy's extension guide they use import_array() to accomplish the same goal that I used _import_array() for. When I tried using import_array(), on a mac I got an error. So you may need to try both commands and see which one works.
By the way you can use C++ std::vector in the call to PyArray_SimpleNewFromData
.
If your std::vector is my_vector
, replace fArray
with &my_vector[0]
. &my_vector[0]
allows you to access the pointer that stores the data in my_vector
.