[Numpy-discussion] Returning the same dtype in Cython as np.argmax
Keith Goodman
kwgoodman@gmail....
Tue Jun 7 15:17:43 CDT 2011
What is the rule to determine the dtype returned by numpy functions
that return indices such as np.argmax?
I assumed that np.argmax() returned the same dtype as np.int_. That
works on linux32/64 and win32 but on win-amd64 np.int_ is int32 and
np.argmax() returns int64.
Someone suggested using intp. But I can't figure out how to do that in
Cython since I am unable to cimport NPY_INTP. So this doesn't work:
from numpy cimport NPY_INTP
cdef np.ndarray[np.intp_t, ndim=1] output = PyArray_EMPTY(1, dims, NPY_INTP, 0)
Is there another way? All I can think of is checking whether np.intp
is np.int32 or int64 when I template the code.
More information about the NumPy-Discussion
mailing list