From 5bf7fea5c2f71926b06c48644b20f48ae96c477f Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Tue, 27 Oct 2009 20:18:02 +0100 Subject: [PATCH] numpy.pxd: Add intp_t and uintp_t --- Cython/Includes/numpy.pxd | 6 ++++-- tests/run/numpy_test.pyx | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cython/Includes/numpy.pxd b/Cython/Includes/numpy.pxd index 1d84e9fb..26af3b06 100644 --- a/Cython/Includes/numpy.pxd +++ b/Cython/Includes/numpy.pxd @@ -26,6 +26,7 @@ cdef extern from "Python.h": cdef extern from "numpy/arrayobject.h": ctypedef Py_intptr_t npy_intp + ctypedef size_t npy_uintp cdef enum NPY_TYPES: NPY_BOOL @@ -193,7 +194,7 @@ cdef extern from "numpy/arrayobject.h": cdef bint little_endian = ((&endian_detector)[0] != 0) ndim = PyArray_NDIM(self) - + if sizeof(npy_intp) != sizeof(Py_ssize_t): copy_shape = 1 else: @@ -735,7 +736,8 @@ ctypedef double complex complex128_t # numpy.int corresponds to 'l' and numpy.long to 'q' ctypedef npy_long int_t ctypedef npy_longlong long_t - +ctypedef npy_intp intp_t +ctypedef npy_uintp uintp_t ctypedef npy_ulong uint_t ctypedef npy_ulonglong ulong_t diff --git a/tests/run/numpy_test.pyx b/tests/run/numpy_test.pyx index c55ed9fc..187737d0 100644 --- a/tests/run/numpy_test.pyx +++ b/tests/run/numpy_test.pyx @@ -140,6 +140,8 @@ try: >>> test_dtype(np.long, inc1_long_t) >>> test_dtype(np.float, inc1_float_t) >>> test_dtype(np.double, inc1_double_t) + >>> test_dtype(np.intp, inc1_intp_t) + >>> test_dtype(np.uintp, inc1_uintp_t) >>> test_dtype(np.longdouble, inc1_longdouble_t) @@ -315,6 +317,8 @@ def inc1_long_t(np.ndarray[np.long_t] arr): arr[1] += 1 def inc1_float_t(np.ndarray[np.float_t] arr): arr[1] += 1 def inc1_double_t(np.ndarray[np.double_t] arr): arr[1] += 1 def inc1_longdouble_t(np.ndarray[np.longdouble_t] arr): arr[1] += 1 +def inc1_intp_t(np.ndarray[np.intp_t] arr): arr[1] += 1 +def inc1_uintp_t(np.ndarray[np.uintp_t] arr): arr[1] += 1 # The tests below only work on platforms that has the given types def inc1_int32_t(np.ndarray[np.int32_t] arr): arr[1] += 1 -- 2.26.2