@@ -133,7 +133,7 @@ class BufferWrapper {
133133 // Constructor with no shape or type checking.
134134 BufferWrapper (std::string name, const py::object &src, bool optional)
135135 : BufferWrapper() {
136- if (optional && (src.ptr () == Py_None ))
136+ if (optional && (src.is_none () ))
137137 return ;
138138 // std::cerr << "BufferWrapper ctor " << name << " src = " << src.ptr() << ")" << std::endl;
139139 if (PyObject_GetBuffer (src.ptr (), view.get (),
@@ -156,27 +156,27 @@ class BufferWrapper {
156156 std::vector<int > shape)
157157 : BufferWrapper(name, src, optional) {
158158
159- // std::cerr << "BufferWrapper start 4-arg ctor" << std::endl;
159+ std::cerr << " BufferWrapper start 4-arg ctor" << std::endl;
160160
161161 // "optional" items will cause the parent constructor to
162162 // succeed, but will leave buffer pointer unset.
163163 if (view->buf == NULL ) {
164- // std::cerr << "BufferWrapper: view->buf == NULL, return" << std::endl;
164+ std::cerr << " BufferWrapper: view->buf == NULL, return" << std::endl;
165165 return ;
166166 }
167167
168168 if (!check_buffer_type<T>(*(view.get ()))) {
169- // std::cerr << "BufferWrapper: view invalid type = " << type_name<T>() << std::endl;
169+ std::cerr << " BufferWrapper: view invalid type = " << type_name<T>() << std::endl;
170170 throw dtype_exception (name, type_name<T>());
171171 }
172172
173173 std::vector<int > vshape;
174- // std::cerr << "BufferWrapper: vshape = ";
174+ std::cerr << " BufferWrapper: vshape = " ;
175175 for (int i=0 ; i<view->ndim ; i++) {
176- // std::cerr << view->shape[i] << ",";
176+ std::cerr << view->shape [i] << " ," ;
177177 vshape.push_back (view->shape [i]);
178178 }
179- // std::cerr << std::endl;
179+ std::cerr << std::endl;
180180
181181 // Note special value -1 is as in numpy -- matches a single
182182 // axis. Special value -2 is treated as an ellipsis -- can be
@@ -205,6 +205,7 @@ class BufferWrapper {
205205 std::ostringstream s;
206206 s << " Expected " << shape_string (shape) << " but got " <<
207207 shape_string (vshape) << " ." ;
208+ std::cerr << s.str () << std::endl;
208209 throw shape_exception (name, s.str ());
209210 }
210211 }
@@ -229,3 +230,7 @@ class BufferWrapper {
229230private:
230231 std::shared_ptr<Py_buffer> view;
231232};
233+
234+
235+ // Convert an n-dimensional array into a list of array slices.
236+ py::list list_of_arrays (py::object input);
0 commit comments