[Numpy-discussion] PyArray_FROM_OF from Cython

David Warde-Farley dwf@cs.toronto....
Thu Oct 8 17:28:32 CDT 2009

I'm trying to use PyArray_FROM_OF from Cython and the generated C code  
keeps crashing.  Dag said on the Cython list that he wasn't sure what  
was going on, so maybe someone here will have an idea.

The line that gdb says is crashing is:

#0  0x00e48287 in __pyx_pf_3_vq_vq (__pyx_self=0x0,  
__pyx_args=0xca2d8, __pyx_kwds=0x0) at _vq_rewrite.c:1025
1025	  __pyx_t_1 = PyArray_FROM_OF(((PyObject *)__pyx_v_obs),  
__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename =  
__pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto  

obs and obs_a are both cdef'd np.ndarrays, and the former (obs) is  
passed in as an argument.

I define flags as
	cdef int flags = np.NPY_CONTIGUOUS | np.NPY_ALIGNED | np.NPY_NOTSWAPPED

and then the line that crashes is

	obs_a = np.PyArray_FROM_OF(obs, flags)

Does anyone know what I'm doing wrong?

(I know I could use np.ascontiguous, but as far as I can tell this  
_should_ work)


More information about the NumPy-Discussion mailing list