So I found how to return numpy.array from boost::python?. However, like this I have to write this function for int, float, double separately. Is it possible to avoid this using templates? I would somehow need to convert with T to an entry to the enumeration of NPY data types. Or are there other options?
template<typename T>
boost::python::object getNumpyArray(std::vector<T>& vector)
{
npy_intp shape[1] = { vector.size() };
//Here I would need to replace NPY_DOUBLE with some conversion of T
PyObject* obj = PyArray_SimpleNewFromData(1, shape, NPY_DOUBLE, vector.data());
boost::python::handle<> handle(obj);
boost::python::numeric::array arr(handle);
return arr.copy();
}