我有一个用python编写的预处理器。这个预处理器计算未知数量的numpy数组。它们存储在一个列表中。为了进一步计算,我需要阅读cpp中numpy数组的列表。我不知道如何将列表中的元素转换为数组类型。在
在主.py在
import numpy as np
import myCPPAlgo
my_list = [ np.zeroes(shape=(10, 10), dtype=np.uint32) for _ in range(10)]
myCPPAlgo.call(my_list)
在主.cpp在
^{pr2}$如何将pybind::句柄转换为py::array\?在
简单地转换为数组:
py::array_t<uint32_t> casted_array = py::cast<py::array>(array);
。下面是完整的工作示例(模错误检查:)。在和测试代码:
^{pr2}$相关问题 更多 >
编程相关推荐