Fix cython syntax and port to more recent numpy.pxd
This commit is contained in:
parent
4afc982dfc
commit
0093a6aa0f
3 changed files with 12 additions and 4 deletions
|
@ -39,7 +39,7 @@ cdef extern from "loadSimu.hpp" namespace "CosmoTool":
|
|||
|
||||
cdef extern from "loadGadget.hpp" namespace "CosmoTool":
|
||||
|
||||
SimuData *loadGadgetMulti(const char *fname, int id, int flags, int gformat) nogil except +
|
||||
SimuData *loadGadgetMulti(const char *fname, int id, int flags, int gformat) except + nogil
|
||||
void cxx_writeGadget "CosmoTool::writeGadget" (const char * s, SimuData *data) except +
|
||||
|
||||
cdef extern from "safe_gadget.hpp":
|
||||
|
@ -313,6 +313,13 @@ tries to get an array from the object."""
|
|||
references to the object are gone. """
|
||||
pass
|
||||
|
||||
|
||||
cdef extern from "numpy/arrayobject.h":
|
||||
# a little bit awkward: the reference to obj will be stolen
|
||||
# using PyObject* to signal that Cython cannot handle it automatically
|
||||
int PyArray_SetBaseObject(np.ndarray arr, PyObject *obj) except -1 # -1 means there was an error
|
||||
|
||||
|
||||
cdef object wrap_array(void *p, np.uint64_t s, int typ):
|
||||
cdef np.ndarray ndarray
|
||||
cdef ArrayWrapper wrapper
|
||||
|
@ -320,7 +327,8 @@ cdef object wrap_array(void *p, np.uint64_t s, int typ):
|
|||
wrapper = ArrayWrapper()
|
||||
wrapper.set_data(s, typ, p)
|
||||
ndarray = np.array(wrapper, copy=False)
|
||||
ndarray.base = <PyObject*> wrapper
|
||||
#ndarray.base = <PyObject*> wrapper
|
||||
PyArray_SetBaseObject(ndarray, <PyObject*> wrapper)
|
||||
Py_INCREF(wrapper)
|
||||
|
||||
return ndarray
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue