What is confusing is that if you want to create an array you use
chunk = np.array ( [[94.,3.],[44.,4.]], dtype=np.float64)
But if you want to define the type inside a buffer
reference , you use
cdef func1 (np.ndarray[np.float64_t, ndim=2] A):
print A
Notice the difference between np.float64
and np.float64_t
.
My Guesses
I am guessing that a type identifier
is what's created explicitly w/ the Cython C-like typedef
syntax
ctypedef np.float64_t dtype_t
But the numpy type
is just the Python <type 'type'>
type .
>>> type ( np.float64)
<type 'type'>
The Numpy documentation on dtype
s doesn't help me. http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html
in your cython code, you do:
import numpy as np
cimport numpy as np
the first line import numpy module in python space, but the second line just include numpy.pxd in cython space.
you can found numpy.pxd in you cython install folder. It define float64_t as:
ctypedef double npy_float64
ctypedef npy_float64 float64_t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With