Return an std::vector to python as a numpy array
std::vector<std::vector<double>>
does not have the memory layout of a 2D builtin array, so that py::array(vect_arr.size(), vect_arr.data());
will not work.
It looks like the py::cast does do the proper copy conversions and propagates the values from the vector to a new numpy array, but this line:
vect_arr[i][j] = vals[i*shape_1 + j*shape_2] * 2;
is not right. It should be:
vect_arr[i][j] = vals[i*shape_2 + j] * 2;