Skip to content

Commit 7562381

Browse files
author
izaid
committed
Updates to match libdynd
1 parent 1808d7a commit 7562381

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

dynd/include/array_functions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ inline dynd::nd::array nd_fields(const dynd::nd::array &n, PyObject *field_list)
362362
// Allocate the new memory block.
363363
size_t arrmeta_size = result_tp.get_arrmeta_size();
364364
dynd::nd::array result =
365-
dynd::nd::make_array(result_tp, n->get_data(), n.get_owner() ? n.get_owner() : n, n.get_flags());
365+
dynd::nd::make_array(result_tp, const_cast<char *>(n.cdata()), n.get_owner() ? n.get_owner() : n, n.get_flags());
366366

367367
// First copy all the array data type arrmeta
368368
dynd::ndt::type tmp_dt = result_tp;

dynd/src/array_as_numpy.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ PyObject *pydynd::array_as_numpy(PyObject *a_obj, bool allow_copy)
582582
else {
583583
// Create a view directly to the dynd array
584584
pyobject_ownref result(PyArray_NewFromDescr(
585-
&PyArray_Type, (PyArray_Descr *)numpy_dtype.release(), (int)ndim, shape.get(), strides.get(), a->get_data(),
585+
&PyArray_Type, (PyArray_Descr *)numpy_dtype.release(), (int)ndim, shape.get(), strides.get(),
586+
const_cast<char *>(a.cdata()),
586587
((a.get_flags() & nd::write_access_flag) ? NPY_ARRAY_WRITEABLE : 0) | NPY_ARRAY_ALIGNED, NULL));
587588

588589
#if NPY_API_VERSION >= 7 // At least NumPy 1.7

dynd/src/array_as_pep3118.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,17 @@ int pydynd::array_getbuffer_pep3118(PyObject *ndo, Py_buffer *buffer, int flags)
253253
throw runtime_error("array_getbuffer_pep3118 called on a non-array");
254254
}
255255
nd::array &n = pydynd::array_to_cpp_ref(ndo);
256-
const nd::array_preamble *preamble = n.get();
257256
ndt::type tp = n.get_type();
258257

259258
// Check if a writable buffer is requested
260259
if ((flags & PyBUF_WRITABLE) && !(n.get_flags() & nd::write_access_flag)) {
261260
throw runtime_error("dynd array is not writable");
262261
}
263262
buffer->readonly = ((n.get_flags() & nd::write_access_flag) == 0);
264-
buffer->buf = preamble->get_data();
263+
buffer->buf = const_cast<char *>(n.cdata());
265264

266265
if (tp.get_id() == bytes_id || tp.get_id() == fixed_bytes_id) {
267-
array_getbuffer_pep3118_bytes(tp, n.get()->metadata(), n->get_data(), buffer, flags);
266+
array_getbuffer_pep3118_bytes(tp, n.get()->metadata(), const_cast<char *>(n.cdata()), buffer, flags);
268267
return 0;
269268
}
270269

0 commit comments

Comments
 (0)