Mercurial > pytave
comparison octave_to_python.cc @ 326:37df9bd607ed
Delete dead code in legacy object conversion
* octave_to_python.cc (pytave::copy_octarray_to_pyarrobj<PyObject *, Cell>,
pytave::octmap_to_pyobject): Delete.
* python_to_octave.cc (pytave::copy_pyarrobj_to_octarray<PyObject *, Cell>,
pytave::pydict_to_octmap, pytave::pylist_to_cellarray,
pytave::pytuple_to_cellarray): Delete.
(pytave::pyobj_to_octvalue): Delete dict, list, and tuple checks.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Sat, 13 Aug 2016 19:57:49 -0700 |
parents | fd5881d48238 |
children | c081e30c2f64 |
comparison
equal
deleted
inserted
replaced
325:fd5881d48238 | 326:37df9bd607ed |
---|---|
74 offset + i*PyArray_STRIDE (pyarr, dimension)); | 74 offset + i*PyArray_STRIDE (pyarr, dimension)); |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 template <> | |
80 void | |
81 copy_octarray_to_pyarrobj<PyObject *, Cell> (PyArrayObject *pyarr, | |
82 const Cell& matrix, | |
83 const unsigned int matindex, | |
84 const unsigned int matstride, | |
85 const int dimension, | |
86 const unsigned int offset) | |
87 { | |
88 unsigned char *ptr = (unsigned char*) PyArray_DATA (pyarr); | |
89 if (dimension == PyArray_NDIM (pyarr) - 1) | |
90 { | |
91 // Last dimension, base case | |
92 for (int i = 0; i < PyArray_DIM (pyarr, dimension); i++) | |
93 { | |
94 object pyobj; | |
95 octvalue_to_pyobj (pyobj, matrix.elem (matindex + i*matstride)); | |
96 Py_INCREF (pyobj.ptr ()); | |
97 *(PyObject **)&ptr[offset + i*PyArray_STRIDE (pyarr, dimension)] | |
98 = pyobj.ptr (); | |
99 } | |
100 } | |
101 else | |
102 { | |
103 for (int i = 0; i < PyArray_DIM (pyarr, dimension); i++) | |
104 { | |
105 copy_octarray_to_pyarrobj<PyObject *, Cell> ( | |
106 pyarr, | |
107 matrix, | |
108 matindex + i*matstride, | |
109 matstride * PyArray_DIM (pyarr, dimension), | |
110 dimension + 1, | |
111 offset + i*PyArray_STRIDE (pyarr, dimension)); | |
112 } | |
113 } | |
114 } | |
115 | |
116 static PyArrayObject * | 79 static PyArrayObject * |
117 createPyArr (const dim_vector& dims, int pyarrtype) | 80 createPyArr (const dim_vector& dims, int pyarrtype) |
118 { | 81 { |
119 int len = dims.length (); | 82 int len = dims.length (); |
120 npy_intp dimensions[len]; | 83 npy_intp dimensions[len]; |
212 } | 175 } |
213 | 176 |
214 py_object = sequence; | 177 py_object = sequence; |
215 } | 178 } |
216 | 179 |
217 static void | |
218 octmap_to_pyobject (boost::python::object& py_object, | |
219 const octave_map& map) | |
220 { | |
221 py_object = boost::python::dict (); | |
222 string_vector keys = map.keys (); | |
223 | |
224 for (octave_idx_type i = 0 ; i < keys.numel (); i++) | |
225 { | |
226 boost::python::object py_val; | |
227 const Cell c = map.contents (keys[i]); | |
228 octvalue_to_pyarr (py_val, c); | |
229 py_object[keys[i]] = py_val; | |
230 } | |
231 } | |
232 | |
233 inline PyObject * | 180 inline PyObject * |
234 python_integer_value (int32_t value) | 181 python_integer_value (int32_t value) |
235 { | 182 { |
236 #if PY_VERSION_HEX >= 0x03000000 | 183 #if PY_VERSION_HEX >= 0x03000000 |
237 return PyLong_FromLong (value); | 184 return PyLong_FromLong (value); |