Commit 3b2990b3 by Gael varoquaux

BUG: Fix the OWNDATA flags of the array

parent 44bc27c8
...@@ -40,4 +40,10 @@ def py_compute(int size): ...@@ -40,4 +40,10 @@ def py_compute(int size):
# new Python object pointing to the existing data # new Python object pointing to the existing data
ndarray = np.PyArray_SimpleNewFromData(1, shape, ndarray = np.PyArray_SimpleNewFromData(1, shape,
np.NPY_INT, <void *> array) np.NPY_INT, <void *> array)
# Tell Python that it can deallocate the memory when the ndarray
# object gets garbage collected
# As the OWNDATA flag of an array is read-only in Python, we need to
# call the C function PyArray_UpdateFlags
np.PyArray_UpdateFlags(ndarray, ndarray.flags.num | np.NPY_OWNDATA)
return ndarray return ndarray
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment