numpy.pxd: Add intp_t and uintp_t
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 27 Oct 2009 19:18:02 +0000 (20:18 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Tue, 27 Oct 2009 19:18:02 +0000 (20:18 +0100)
Cython/Includes/numpy.pxd
tests/run/numpy_test.pyx

index 1d84e9fb7182b9e96ba89e9841b36d2ffd2b4443..26af3b060dbb2a03a6a9d83895b37a3d1f954036 100644 (file)
@@ -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 = ((<char*>&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
index c55ed9fc009b19818f34fe4ea0c5c6e8ad2edcda..187737d074c2ff1553a1dc3c0d6307848d8ba030 100644 (file)
@@ -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