comparison VectorConversion.h @ 40:fa3f80d4e340

2D array conversion (incorrect, crashing)
author Chris Cannam
date Wed, 26 Nov 2014 15:58:46 +0000
parents 7e7f2f7d9542
children 55fcd0e3e513
comparison
equal deleted inserted replaced
39:13dcfe8c7ed7 40:fa3f80d4e340
85 ValueError getError() const; 85 ValueError getError() const;
86 86
87 std::vector<float> PyValue_To_FloatVector (PyObject*) const; 87 std::vector<float> PyValue_To_FloatVector (PyObject*) const;
88 std::vector<float> PyArray_To_FloatVector (PyObject *) const; 88 std::vector<float> PyArray_To_FloatVector (PyObject *) const;
89 std::vector<float> PyList_To_FloatVector (PyObject*) const; 89 std::vector<float> PyList_To_FloatVector (PyObject*) const;
90 90 std::vector<std::vector<float> > Py2DArray_To_FloatVector (PyObject *) const;
91
91 PyObject *PyValue_From_StringVector(const std::vector<std::string> &) const; 92 PyObject *PyValue_From_StringVector(const std::vector<std::string> &) const;
92 PyObject *PyArray_From_FloatVector(const std::vector<float> &) const; 93 PyObject *PyArray_From_FloatVector(const std::vector<float> &) const;
93 94
94 private: 95 private:
95 std::string PyValue_Get_TypeName(PyObject*) const; 96 std::string PyValue_Get_TypeName(PyObject*) const;
98 /// Convert DTYPE type 1D NumpyArray to std::vector<RET> 99 /// Convert DTYPE type 1D NumpyArray to std::vector<RET>
99 template<typename RET, typename DTYPE> 100 template<typename RET, typename DTYPE>
100 std::vector<RET> PyArray_Convert(void* raw_data_ptr, 101 std::vector<RET> PyArray_Convert(void* raw_data_ptr,
101 int length, 102 int length,
102 size_t strides) const { 103 size_t strides) const {
104
105 std::cerr << "PyArray_Convert: raw pointer is " << (long long)(raw_data_ptr) << std::endl;
103 106
104 std::vector<RET> v(length); 107 std::vector<RET> v(length);
105 108
106 /// check if the array is continuous, if not use strides info 109 /// check if the array is continuous, if not use strides info
107 if (sizeof(DTYPE) != strides) { 110 if (sizeof(DTYPE) != strides) {