Going through some source code in scikit-learn, I noticed in tree.pxd
some of the following type declarations:
import numpy as np
cimport numpy as np
ctypedef np.npy_float32 DTYPE_t # Type of X
ctypedef np.npy_float64 DOUBLE_t # Type of y, sample_weight
ctypedef np.npy_intp SIZE_t # Type for indices and counters
ctypedef np.npy_int32 INT32_t # Signed 32 bit integer
ctypedef np.npy_uint32 UINT32_t # Unsigned 32 bit integer
I know there is some discussion on the Cython docs here about the difference between C types and cython types, but these seem to be types from numpy, and they aren't mentioned in the documentation.
I'm confused about what types I should be using. For indexes, should I be using SIZE_t
as defined above, or unsigned int
? Is it really necessary for these ctypedef
s to exist?