Magnus Lie Hetland wrote: > Hi! > > I've been trying to get the simple Cython+NumPy example from Robert > Bradshaw's slides to work: > >> # footest.pyx > >> cimport numpy >> >> def sum(x): >> cdef numpy.ndarray[int, ndim=1] arr = x >> cdef int i, s = 0 >> for i in range(arr.shape[0]): >> s += arr[i] >> return s > > I get it to compile/link, but then I try to actually use it, with the > following code: > >> import footest >> import numpy as np >> >> a = np.arange(1000, dtype=np.int) >> print footest.sum(a) > > The np.int shouldn't be necessary -- and I started without it -- but > even *with* it, I get the following error:
BTW I believe NumPy has switched the default dtype to float in recent versions, so better leave it in. (But I'm not 100% sure about this) -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
