I have the following class:
class PyWav {
public:
static inline boost::python::object sdVecToNumpyArray(std::vector<double> const& vec)
{
npy_intp size = vec.size();
double * data = size ? const_cast<double *>(&vec[0]) : static_cast<double *>(NULL);
PyObject * pyObj = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data);
boost::python::handle<> handle ( pyObj );
boost::python::numeric::array arr(handle);
return arr.copy();
}
// Access function
inline boost::python::numeric::array toNumPy()
{
std::vector<double> v = Signal(); // get the vector
boost::python::numeric::array arr = Lib::python::PyWav::sdVecToNumpyArray(
v);
return arr;
}
};
The problem is I do not know how to access the stdVecToNumpyArray and pass through the vector? I want the method "toNumPy()" to be open to the user, but, not the sdVecToNumpyArray
I get the following error:
error: conversion from ‘boost::python::api::object’ to non-scalar type ‘boost::python::numeric::array’ requested v);
Anyone have any ideas?