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
cdef dtype_t val
while not np.PyArray_ITER_NOTDONE (it):
val = (<dtype_t*>np.PyArray_ITER_DATA (it))[0]
print val
out += val
np.PyArray_ITER_NEXT (it)
return out
--------------
test_sum.py:
import sum
import numpy as np
arr = np.arange (10)
print sum.sum (arr)
--------------
result:
TypeError: cannot create 'numpy.flatiter' instances
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev