| 268 | |
| 269 | template<typename Numeric> |
| 270 | PyObject* get_array(const std::vector<Numeric>& v) |
| 271 | { |
| 272 | detail::_interpreter::get(); //interpreter needs to be initialized for the numpy commands to work |
| 273 | NPY_TYPES type = select_npy_type<Numeric>::type; |
| 274 | if (type == NPY_NOTYPE) |
| 275 | { |
| 276 | std::vector<double> vd(v.size()); |
| 277 | npy_intp vsize = v.size(); |
| 278 | std::copy(v.begin(),v.end(),vd.begin()); |
| 279 | PyObject* varray = PyArray_SimpleNewFromData(1, &vsize, NPY_DOUBLE, (void*)(vd.data())); |
| 280 | return varray; |
| 281 | } |
| 282 | |
| 283 | npy_intp vsize = v.size(); |
| 284 | PyObject* varray = PyArray_SimpleNewFromData(1, &vsize, type, (void*)(v.data())); |
| 285 | return varray; |
| 286 | } |
| 287 | |
| 288 | template<typename Numeric> |
| 289 | PyObject* get_2darray(const std::vector<::std::vector<Numeric>>& v) |
no test coverage detected