Neal Becker wrote:
> Made some more progress.  Need:
> 
> Added to numpy.pyd:
>     bint PyArray_ITER_NOTDONE (flatiter x) nogil
>     void PyArray_ITER_NEXT (flatiter x) nogil
>     void* PyArray_ITER_DATA (flatiter x) nogil
> 
> --------------
> Test module sum.pyx:
> import numpy as np
> cimport numpy as np
> 
> dtype = np.double
> ctypedef double dtype_t
> 
> np.import_array()
> 
> def sum (in1):
>     cdef:
>         np.flatiter it
>         dtype_t out = 0
> 
>     in1 = np.asarray (in1, dtype)
>     shape = in1.shape
>     it = np.flatiter (in1)  <<< problem here


Declare and use PyArray_IterNew, see "Iterators" in

http://docs.scipy.org/doc/numpy/reference/c-api.array.html

I'm not sure whether this call really returns a "flatiter" instance (in 
which case you can keep the others as is). If it returns something else 
than "flatiter", you can just use "object" everywhere you now use 
"flatiter" and it should work (though perhaps not be safe, i.e. if you 
pass a Python tuple to ITER_NOTDONE you get to keep the pieces. So use 
flatiter as the type if possible.).

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

Reply via email to