Dag Sverre Seljebotn wrote:
> Or if you do not know the number of dimensions:
> 
> cdef np.ndarray Xc = X
> if Xc.dtype != np.float or not Xc.flags["C_CONTIGUOUS"]:
>      raise something
> cdef float* buf = <float*>Xc.data
> 

I'm changing my recommondation to this instead:

if X.dtype != np.float or not X.flags["C_CONTIGUOUS"]:
      raise something
cdef float* buf = <float*>np.PyArray_DATA(X)

(I suppose the "X.data" could be removed in the future because it might 
be potentially confusing that it does something different if X is typed 
as ndarray rather than if not:

cdef ndarray Xc = X
X.data # is a Python buffer instance
Xc.data # is a char*

PyArray_DATA can always be used if you want the latter one. Opinions?)

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to