Hi all, What is currently the correct way of defining an enum? I am trying to call a NumPy function with an enum as its third argument, and the following does not compile:
cimport numpy as np np.import_array() cdef enum NPY_SEARCHSIDE: NPY_SEARCHLEFT = 0 NPY_SEARCHRIGHT = 1 cdef sort_something(): cdef np.ndarray[double, ndim=1] sample_prob = np.empty(5, np.float64) cdef np.ndarray[double, ndim=1] cum_prob = np.empty(5, np.float64) cdef NPY_SEARCHSIDE side = NPY_SEARCHRIGHT results = np.PyArray_SearchSorted(cum_prob, sample_prob, side) It fails with: enum.c:1081:3: error: incompatible type for argument 3 of ‘(struct PyObject * (*)(struct PyArrayObject *, struct PyObject *, enum NPY_SEARCHSIDE))*(PyArray_API + 1048u)’ enum.c:1081:3: note: expected ‘NPY_SEARCHSIDE’ but argument is of type ‘struct PyObject *’ I tried different ways of defining the enum, e.g. cdef extern from "ndarraytypes.h": cpdef enum NPY_SEARCHSIDE: NPY_SEARCHLEFT = 0 NPY_SEARCHRIGHT = 1 But that doesn't work either. Any suggestions would be appreciated. Regards Stéfan
_______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel