[Scipy-svn] r6747 - trunk/scipy/ndimage/src

scipy-svn@scip... scipy-svn@scip...
Sat Sep 11 19:57:31 CDT 2010


Author: ptvirtan
Date: 2010-09-11 19:57:31 -0500 (Sat, 11 Sep 2010)
New Revision: 6747

Modified:
   trunk/scipy/ndimage/src/nd_image.c
   trunk/scipy/ndimage/src/nd_image.h
   trunk/scipy/ndimage/src/ni_filters.c
   trunk/scipy/ndimage/src/ni_filters.h
   trunk/scipy/ndimage/src/ni_fourier.c
   trunk/scipy/ndimage/src/ni_fourier.h
   trunk/scipy/ndimage/src/ni_interpolation.c
   trunk/scipy/ndimage/src/ni_interpolation.h
   trunk/scipy/ndimage/src/ni_measure.c
   trunk/scipy/ndimage/src/ni_measure.h
   trunk/scipy/ndimage/src/ni_morphology.c
   trunk/scipy/ndimage/src/ni_morphology.h
   trunk/scipy/ndimage/src/ni_support.c
   trunk/scipy/ndimage/src/ni_support.h
Log:
BUG: ndimage: replace long -> npy_intp, for better Windows support

- Use npy_intp instead of long
- Rename "maybelong" -> "npy_intp".
- Use the "n" ParseTuple code, but fall back to "l" on Python 2.4

Thanks to Christoph Gohlke for the patch.

Modified: trunk/scipy/ndimage/src/nd_image.c
===================================================================
--- trunk/scipy/ndimage/src/nd_image.c	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/nd_image.c	2010-09-12 00:57:31 UTC (rev 6747)
@@ -97,20 +97,20 @@
 }
 
 /* Convert an Long sequence */
-static maybelong
-NI_ObjectToLongSequenceAndLength(PyObject *object, maybelong **sequence)
+static npy_intp
+NI_ObjectToLongSequenceAndLength(PyObject *object, npy_intp **sequence)
 {
-    long *pa, ii;
-    PyArrayObject *array = NA_InputArray(object, PyArray_LONG, NPY_CARRAY);
-    maybelong length = PyArray_SIZE(array);
+    npy_intp *pa, ii;
+    PyArrayObject *array = NA_InputArray(object, PyArray_INTP, NPY_CARRAY);
+    npy_intp length = PyArray_SIZE(array);
 
-    *sequence = (maybelong*)malloc(length * sizeof(maybelong));
+    *sequence = (npy_intp*)malloc(length * sizeof(npy_intp));
     if (!*sequence) {
         PyErr_NoMemory();
         Py_XDECREF(array);
         return -1;
     }
-    pa = (long*)PyArray_DATA(array);
+    pa = (npy_intp*)PyArray_DATA(array);
     for(ii = 0; ii < length; ii++)
         (*sequence)[ii] = pa[ii];
     Py_XDECREF(array);
@@ -118,7 +118,7 @@
 }
 
 static int
-NI_ObjectToLongSequence(PyObject *object, maybelong **sequence)
+NI_ObjectToLongSequence(PyObject *object, npy_intp **sequence)
 {
     return NI_ObjectToLongSequenceAndLength(object, sequence) >= 0;
 }
@@ -131,13 +131,24 @@
 {
     PyArrayObject *input = NULL, *output = NULL, *weights = NULL;
     int axis, mode;
+    double cval;
+#if PY_VERSION_HEX < 0x02050000
     long origin;
-    double cval;
+#define FMT "l"
+#else
+    npy_intp origin;
+#define FMT "n"
+#endif
 
-    if (!PyArg_ParseTuple(args, "O&O&iO&idl", NI_ObjectToInputArray, &input,
-                                    NI_ObjectToInputArray, &weights, &axis,
-                                    NI_ObjectToOutputArray, &output, &mode, &cval, &origin))
+    if (!PyArg_ParseTuple(args, "O&O&iO&id" FMT,
+                          NI_ObjectToInputArray, &input,
+                          NI_ObjectToInputArray, &weights, &axis,
+                          NI_ObjectToOutputArray, &output, &mode, &cval,
+                          &origin))
         goto exit;
+
+#undef FMT
+
     if (!NI_Correlate1D(input, weights, axis, output,
                                             (NI_ExtendMode)mode, cval, origin))
         goto exit;
@@ -151,13 +162,15 @@
 static PyObject *Py_Correlate(PyObject *obj, PyObject *args)
 {
     PyArrayObject *input = NULL, *output = NULL, *weights = NULL;
-    maybelong *origin = NULL;
+    npy_intp *origin = NULL;
     int mode;
     double cval;
 
     if (!PyArg_ParseTuple(args, "O&O&O&idO&", NI_ObjectToInputArray, &input,
-                    NI_ObjectToInputArray, &weights, NI_ObjectToOutputArray, &output,
-                    &mode, &cval, NI_ObjectToLongSequence, &origin))
+                          NI_ObjectToInputArray, &weights,
+                          NI_ObjectToOutputArray, &output,
+                         &mode, &cval,
+                         NI_ObjectToLongSequence, &origin))
         goto exit;
     if (!NI_Correlate(input, weights, output, (NI_ExtendMode)mode, cval,
                                         origin))
@@ -175,15 +188,23 @@
 {
     PyArrayObject *input = NULL, *output = NULL;
     int axis, mode;
+#if PY_VERSION_HEX < 0x02050000
     long filter_size, origin;
+#define FMT "l"
+#else
+    npy_intp filter_size, origin;
+#define FMT "n"
+#endif
     double cval;
 
-    if (!PyArg_ParseTuple(args, "O&liO&idl", NI_ObjectToInputArray, &input,
-                                        &filter_size, &axis, NI_ObjectToOutputArray, &output,
-                                        &mode, &cval, &origin))
+    if (!PyArg_ParseTuple(args, "O&" FMT "iO&id" FMT,
+                          NI_ObjectToInputArray, &input,
+                          &filter_size, &axis,
+                          NI_ObjectToOutputArray, &output,
+                          &mode, &cval, &origin))
         goto exit;
     if (!NI_UniformFilter1D(input, filter_size, axis, output,
-                                                                             (NI_ExtendMode)mode, cval, origin))
+                            (NI_ExtendMode)mode, cval, origin))
         goto exit;
 exit:
     Py_XDECREF(input);
@@ -195,13 +216,22 @@
 {
     PyArrayObject *input = NULL, *output = NULL;
     int axis, mode, minimum;
+#if PY_VERSION_HEX < 0x02050000
     long filter_size, origin;
+#define FMT "l"
+#else
+    npy_intp filter_size, origin;
+#define FMT "n"
+#endif
     double cval;
 
-    if (!PyArg_ParseTuple(args, "O&liO&idli", NI_ObjectToInputArray, &input,
-                                        &filter_size, &axis, NI_ObjectToOutputArray, &output,
-                                        &mode, &cval, &origin, &minimum))
+    if (!PyArg_ParseTuple(args, "O&" FMT "iO&id" FMT "i",
+                          NI_ObjectToInputArray, &input,
+                          &filter_size, &axis,
+                          NI_ObjectToOutputArray, &output,
+                          &mode, &cval, &origin, &minimum))
         goto exit;
+#undef FMT
     if (!NI_MinOrMaxFilter1D(input, filter_size, axis, output,
                                                             (NI_ExtendMode)mode, cval, origin, minimum))
         goto exit;
@@ -215,15 +245,18 @@
 {
     PyArrayObject *input = NULL, *output = NULL, *footprint = NULL;
     PyArrayObject *structure = NULL;
-    maybelong *origin = NULL;
+    npy_intp *origin = NULL;
     int mode, minimum;
     double cval;
 
-    if (!PyArg_ParseTuple(args, "O&O&O&O&idO&i", NI_ObjectToInputArray,
-                                        &input, NI_ObjectToInputArray, &footprint,
+    if (!PyArg_ParseTuple(args, "O&O&O&O&idO&i",
+                          NI_ObjectToInputArray, &input,
+                          NI_ObjectToInputArray, &footprint,
                                         NI_ObjectToOptionalInputArray, &structure,
-                                        NI_ObjectToOutputArray, &output, &mode, &cval,
-                                        NI_ObjectToLongSequence, &origin, &minimum))
+                          NI_ObjectToOutputArray, &output,
+                          &mode, &cval,
+                          NI_ObjectToLongSequence, &origin,
+                          &minimum))
         goto exit;
     if (!NI_MinOrMaxFilter(input, footprint, structure, output,
                                                 (NI_ExtendMode)mode, cval, origin, minimum))
@@ -241,13 +274,15 @@
 static PyObject *Py_RankFilter(PyObject *obj, PyObject *args)
 {
     PyArrayObject *input = NULL, *output = NULL, *footprint = NULL;
-    maybelong *origin = NULL;
+    npy_intp *origin = NULL;
     int mode, rank;
     double cval;
 
-    if (!PyArg_ParseTuple(args, "O&iO&O&idO&", NI_ObjectToInputArray,
-                                        &input, &rank, NI_ObjectToInputArray, &footprint,
-                                        NI_ObjectToOutputArray, &output, &mode, &cval,
+    if (!PyArg_ParseTuple(args, "O&iO&O&idO&",
+                          NI_ObjectToInputArray, &input, &rank,
+                          NI_ObjectToInputArray, &footprint,
+                          NI_ObjectToOutputArray, &output,
+                          &mode, &cval,
                                         NI_ObjectToLongSequence, &origin))
         goto exit;
     if (!NI_RankFilter(input, rank, footprint, output, (NI_ExtendMode)mode,
@@ -262,12 +297,12 @@
     return PyErr_Occurred() ? NULL : Py_BuildValue("");
 }
 
-static int Py_Filter1DFunc(double *iline, maybelong ilen,
-                                                     double *oline, maybelong olen, void *data)
+static int Py_Filter1DFunc(double *iline, npy_intp ilen,
+                           double *oline, npy_intp olen, void *data)
 {
     PyArrayObject *py_ibuffer = NULL, *py_obuffer = NULL;
     PyObject *rv = NULL, *args = NULL, *tmp = NULL;
-    maybelong ii;
+    npy_intp ii;
     double *po = NULL;
     NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data;
 
@@ -303,16 +338,26 @@
     void *func = Py_Filter1DFunc, *data = NULL;
     NI_PythonCallbackData cbdata;
     int axis, mode;
+#if PY_VERSION_HEX < 0x02050000
     long origin, filter_size;
+#define FMT "l"
+#else
+    npy_intp origin, filter_size;
+#define FMT "n"
+#endif
     double cval;
 
-    if (!PyArg_ParseTuple(args, "O&OliO&idlOO", NI_ObjectToInputArray,
-                &input, &fnc, &filter_size, &axis, NI_ObjectToOutputArray,
-                &output, &mode, &cval, &origin, &extra_arguments, &extra_keywords))
+    if (!PyArg_ParseTuple(args, "O&O" FMT "iO&id" FMT "OO",
+                          NI_ObjectToInputArray, &input,
+                          &fnc, &filter_size, &axis,
+                          NI_ObjectToOutputArray, &output,
+                          &mode, &cval, &origin,
+                          &extra_arguments, &extra_keywords))
         goto exit;
+#undef FMT
+
     if (!PyTuple_Check(extra_arguments)) {
-        PyErr_SetString(PyExc_RuntimeError,
-                                        "extra_arguments must be a tuple");
+        PyErr_SetString(PyExc_RuntimeError, "extra_arguments must be a tuple");
         goto exit;
     }
     if (!PyDict_Check(extra_keywords)) {
@@ -334,7 +379,7 @@
         goto exit;
     }
     if (!NI_GenericFilter1D(input, func, data, filter_size, axis, output,
-                                                                                (NI_ExtendMode)mode, cval, origin))
+                            (NI_ExtendMode)mode, cval, origin))
         goto exit;
 exit:
     Py_XDECREF(input);
@@ -342,7 +387,7 @@
     return PyErr_Occurred() ? NULL : Py_BuildValue("");
 }
 
-static int Py_FilterFunc(double *buffer, maybelong filter_size,
+static int Py_FilterFunc(double *buffer, npy_intp filter_size,
                                                  double *output, void *data)
 {
     PyArrayObject *py_buffer = NULL;
@@ -377,18 +422,20 @@
     void *func = Py_FilterFunc, *data = NULL;
     NI_PythonCallbackData cbdata;
     int mode;
-    maybelong *origin = NULL;
+    npy_intp *origin = NULL;
     double cval;
 
-    if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO", NI_ObjectToInputArray,
-                                                &input, &fnc, NI_ObjectToInputArray, &footprint,
-                                                NI_ObjectToOutputArray, &output, &mode, &cval,
+    if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO",
+                          NI_ObjectToInputArray, &input,
+                          &fnc,
+                          NI_ObjectToInputArray, &footprint,
+                          NI_ObjectToOutputArray, &output,
+                          &mode, &cval,
                                                 NI_ObjectToLongSequence, &origin,
                                                 &extra_arguments, &extra_keywords))
         goto exit;
     if (!PyTuple_Check(extra_arguments)) {
-        PyErr_SetString(PyExc_RuntimeError,
-                                        "extra_arguments must be a tuple");
+        PyErr_SetString(PyExc_RuntimeError, "extra_arguments must be a tuple");
         goto exit;
     }
     if (!PyDict_Check(extra_keywords)) {
@@ -425,12 +472,22 @@
 {
     PyArrayObject *input = NULL, *output = NULL, *parameters = NULL;
     int axis, filter_type;
+#if PY_VERSION_HEX < 0x02050000
     long n;
+#define FMT "l"
+#else
+    npy_intp n;
+#define FMT "n"
+#endif
 
-    if (!PyArg_ParseTuple(args, "O&O&liO&i", NI_ObjectToInputArray, &input,
-                                        NI_ObjectToInputArray, &parameters, &n, &axis,
-                                        NI_ObjectToOutputArray, &output, &filter_type))
+    if (!PyArg_ParseTuple(args, "O&O&" FMT "iO&i",
+                          NI_ObjectToInputArray, &input,
+                          NI_ObjectToInputArray, &parameters,
+                          &n, &axis,
+                          NI_ObjectToOutputArray, &output,
+                          &filter_type))
         goto exit;
+#undef FMT
 
     if (!NI_FourierFilter(input, parameters, n, axis, output, filter_type))
         goto exit;
@@ -446,12 +503,21 @@
 {
     PyArrayObject *input = NULL, *output = NULL, *shifts = NULL;
     int axis;
+#if PY_VERSION_HEX < 0x02050000
     long n;
+#define FMT "l"
+#else
+    npy_intp n;
+#define FMT "n"
+#endif
 
-    if (!PyArg_ParseTuple(args, "O&O&liO&", NI_ObjectToInputArray, &input,
-                                        NI_ObjectToInputArray, &shifts, &n, &axis,
+    if (!PyArg_ParseTuple(args, "O&O&" FMT "iO&",
+                          NI_ObjectToInputArray, &input,
+                          NI_ObjectToInputArray, &shifts,
+                          &n, &axis,
                                         NI_ObjectToOutputArray, &output))
         goto exit;
+#undef FMT
 
     if (!NI_FourierShift(input, shifts, n, axis, output))
         goto exit;
@@ -468,8 +534,10 @@
     PyArrayObject *input = NULL, *output = NULL;
     int axis, order;
 
-    if (!PyArg_ParseTuple(args, "O&iiO&", NI_ObjectToInputArray, &input,
-                    &order, &axis, NI_ObjectToOutputArray, &output))
+    if (!PyArg_ParseTuple(args, "O&iiO&",
+                          NI_ObjectToInputArray, &input,
+                          &order, &axis,
+                          NI_ObjectToOutputArray, &output))
         goto exit;
 
     if (!NI_SplineFilter1D(input, order, axis, output))
@@ -481,18 +549,22 @@
     return PyErr_Occurred() ? NULL : Py_BuildValue("");
 }
 
-static int Py_Map(maybelong *ocoor, double* icoor, int orank, int irank,
+static int Py_Map(npy_intp *ocoor, double* icoor, int orank, int irank,
                                     void *data)
 {
     PyObject *coors = NULL, *rets = NULL, *args = NULL, *tmp = NULL;
-    maybelong ii;
+    npy_intp ii;
     NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data;
 
     coors = PyTuple_New(orank);
     if (!coors)
         goto exit;
     for(ii = 0; ii < orank; ii++) {
-        PyTuple_SetItem(coors, ii, PyInt_FromLong(ocoor[ii]));
+#if PY_VERSION_HEX < 0x02060000
+        PyTuple_SetItem(coors, ii, PyLong_FromLong(ocoor[ii]));
+#else
+        PyTuple_SetItem(coors, ii, PyLong_FromSsize_t(ocoor[ii]));
+#endif
         if (PyErr_Occurred())
             goto exit;
     }
@@ -529,12 +601,15 @@
     void *func = NULL, *data = NULL;
     NI_PythonCallbackData cbdata;
 
-    if (!PyArg_ParseTuple(args, "O&OO&O&O&O&iidOO", NI_ObjectToInputArray,
-                                                &input, &fnc, NI_ObjectToOptionalInputArray,
-                                                &coordinates, NI_ObjectToOptionalInputArray,
-                                                &matrix, NI_ObjectToOptionalInputArray, &shift,
-                                                NI_ObjectToOutputArray, &output, &order, &mode,
-                                                &cval, &extra_arguments, &extra_keywords))
+    if (!PyArg_ParseTuple(args, "O&OO&O&O&O&iidOO",
+                          NI_ObjectToInputArray, &input,
+                          &fnc,
+                          NI_ObjectToOptionalInputArray, &coordinates,
+                          NI_ObjectToOptionalInputArray, &matrix,
+                          NI_ObjectToOptionalInputArray, &shift,
+                          NI_ObjectToOutputArray, &output,
+                          &order, &mode, &cval,
+                          &extra_arguments, &extra_keywords))
         goto exit;
 
     if (fnc != Py_None) {
@@ -584,10 +659,12 @@
     int mode, order;
     double cval;
 
-    if (!PyArg_ParseTuple(args, "O&O&O&O&iid", NI_ObjectToInputArray,
-                    &input, NI_ObjectToOptionalInputArray, &zoom,
-                    NI_ObjectToOptionalInputArray, &shift, NI_ObjectToOutputArray,
-                    &output, &order, &mode, &cval))
+    if (!PyArg_ParseTuple(args, "O&O&O&O&iid",
+                          NI_ObjectToInputArray, &input,
+                          NI_ObjectToOptionalInputArray, &zoom,
+                          NI_ObjectToOptionalInputArray, &shift,
+                          NI_ObjectToOutputArray, &output,
+                          &order, &mode, &cval))
         goto exit;
 
     if (!NI_ZoomShift(input, zoom, shift, output, order, (NI_ExtendMode)mode,
@@ -605,10 +682,12 @@
 static PyObject *Py_Label(PyObject *obj, PyObject *args)
 {
     PyArrayObject *input = NULL, *output = NULL, *strct = NULL;
-    maybelong max_label;
+    npy_intp max_label;
 
-    if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input,
-                    NI_ObjectToInputArray, &strct, NI_ObjectToOutputArray, &output))
+    if (!PyArg_ParseTuple(args, "O&O&O&",
+                          NI_ObjectToInputArray, &input,
+                          NI_ObjectToInputArray, &strct,
+                          NI_ObjectToOutputArray, &output))
         goto exit;
 
     if (!NI_Label(input, strct, &max_label, output))
@@ -618,7 +697,11 @@
     Py_XDECREF(input);
     Py_XDECREF(strct);
     Py_XDECREF(output);
+#if PY_VERSION_HEX < 0x02050000
     return PyErr_Occurred() ? NULL : Py_BuildValue("l", (long)max_label);
+#else
+    return PyErr_Occurred() ? NULL : Py_BuildValue("n", (npy_intp)max_label);
+#endif
 }
 
 static PyObject *Py_FindObjects(PyObject *obj, PyObject *args)
@@ -627,21 +710,28 @@
     PyObject *result = NULL, *tuple = NULL, *start = NULL, *end = NULL;
     PyObject *slc = NULL;
     int jj;
+#if PY_VERSION_HEX < 0x02050000
     long max_label;
-    maybelong ii, *regions = NULL;
+#define FMT "l"
+#else
+    npy_intp max_label;
+#define FMT "n"
+#endif
+    npy_intp ii, *regions = NULL;
 
-    if (!PyArg_ParseTuple(args, "O&l", NI_ObjectToInputArray, &input,
-                                                &max_label))
+    if (!PyArg_ParseTuple(args, "O&" FMT,
+                          NI_ObjectToInputArray, &input, &max_label))
         goto exit;
+#undef FMT
 
     if (max_label < 0)
         max_label = 0;
     if (max_label > 0) {
         if (input->nd > 0) {
-            regions = (maybelong*)malloc(2 * max_label * input->nd *
-                                                                                                        sizeof(maybelong));
+            regions = (npy_intp*)malloc(2 * max_label * input->nd *
+                                                             sizeof(npy_intp));
         } else {
-            regions = (maybelong*)malloc(max_label * sizeof(maybelong));
+            regions = (npy_intp*)malloc(max_label * sizeof(npy_intp));
         }
         if (!regions) {
             PyErr_NoMemory();
@@ -659,7 +749,7 @@
     }
 
     for(ii = 0; ii < max_label; ii++) {
-        maybelong idx = input->nd > 0 ? 2 * input->nd * ii : ii;
+        npy_intp idx = input->nd > 0 ? 2 * input->nd * ii : ii;
         if (regions[idx] >= 0) {
             PyObject *tuple = PyTuple_New(input->nd);
             if (!tuple) {
@@ -667,8 +757,13 @@
                 goto exit;
             }
             for(jj = 0; jj < input->nd; jj++) {
-                start = PyInt_FromLong(regions[idx + jj]);
-                end = PyInt_FromLong(regions[idx + jj + input->nd]);
+#if PY_VERSION_HEX < 0x02060000
+                start = PyLong_FromLong(regions[idx + jj]);
+                end = PyLong_FromLong(regions[idx + jj + input->nd]);
+#else
+                start = PyLong_FromSsize_t(regions[idx + jj]);
+                end = PyLong_FromSsize_t(regions[idx + jj + input->nd]);
+#endif
                 if (!start || !end) {
                     PyErr_NoMemory();
                     goto exit;
@@ -739,8 +834,10 @@
     PyArrayObject *sampling = NULL;
     int metric;
 
-    if (!PyArg_ParseTuple(args, "O&iO&O&O&", NI_ObjectToInputArray, &input,
-                                                &metric, NI_ObjectToOptionalInputArray, &sampling,
+    if (!PyArg_ParseTuple(args, "O&iO&O&O&",
+                          NI_ObjectToInputArray, &input,
+                          &metric,
+                          NI_ObjectToOptionalInputArray, &sampling,
                                                 NI_ObjectToOptionalOutputArray, &output,
                                                 NI_ObjectToOptionalOutputArray, &features))
         goto exit;
@@ -759,7 +856,8 @@
 {
     PyArrayObject *strct = NULL, *distances = NULL, *features = NULL;
 
-    if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &strct,
+    if (!PyArg_ParseTuple(args, "O&O&O&",
+                          NI_ObjectToInputArray, &strct,
                                                 NI_ObjectToIoArray, &distances,
                                                 NI_ObjectToOptionalOutputArray, &features))
         goto exit;
@@ -777,7 +875,8 @@
 {
     PyArrayObject *input = NULL, *features = NULL, *sampling = NULL;
 
-    if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input,
+    if (!PyArg_ParseTuple(args, "O&O&O&",
+                          NI_ObjectToInputArray, &input,
                                                 NI_ObjectToOptionalInputArray, &sampling,
                                                 NI_ObjectToOutputArray, &features))
         goto exit;
@@ -810,14 +909,16 @@
     int border_value, invert, center_is_true;
     int changed = 0, return_coordinates;
     NI_CoordinateList *coordinate_list = NULL;
-    maybelong *origins = NULL;
+    npy_intp *origins = NULL;
 
-    if (!PyArg_ParseTuple(args, "O&O&O&O&iO&iii", NI_ObjectToInputArray,
-                                                &input, NI_ObjectToInputArray, &strct,
+    if (!PyArg_ParseTuple(args, "O&O&O&O&iO&iii",
+                          NI_ObjectToInputArray, &input,
+                          NI_ObjectToInputArray, &strct,
                                                 NI_ObjectToOptionalInputArray, &mask,
-                                                NI_ObjectToOutputArray, &output, &border_value,
-                                                NI_ObjectToLongSequence, &origins,  &invert,
-                                                &center_is_true, &return_coordinates))
+                          NI_ObjectToOutputArray, &output,
+                          &border_value,
+                          NI_ObjectToLongSequence, &origins,
+                          &invert, &center_is_true, &return_coordinates))
         goto exit;
     if (!NI_BinaryErosion(input, strct, mask, output, border_value,
                                                 origins, invert, center_is_true, &changed,
@@ -850,12 +951,15 @@
     PyArrayObject *array = NULL, *strct = NULL, *mask = NULL;
     PyObject *cobj = NULL;
     int invert, niter;
-    maybelong *origins = NULL;
+    npy_intp *origins = NULL;
 
-    if (!PyArg_ParseTuple(args, "O&O&O&iO&iO", NI_ObjectToIoArray, &array,
-                    NI_ObjectToInputArray, &strct, NI_ObjectToOptionalInputArray,
-                    &mask, &niter, NI_ObjectToLongSequence, &origins, &invert,
-                    &cobj))
+    if (!PyArg_ParseTuple(args, "O&O&O&iO&iO",
+                          NI_ObjectToIoArray, &array,
+                          NI_ObjectToInputArray, &strct,
+                          NI_ObjectToOptionalInputArray,
+                          &mask, &niter,
+                          NI_ObjectToLongSequence, &origins,
+                          &invert, &cobj))
         goto exit;
 
     if (NpyCapsule_Check(cobj)) {

Modified: trunk/scipy/ndimage/src/nd_image.h
===================================================================
--- trunk/scipy/ndimage/src/nd_image.h	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/nd_image.h	2010-09-12 00:57:31 UTC (rev 6747)
@@ -69,7 +69,6 @@
 
 #define NI_MAXDIM NPY_MAXDIMS
 
-typedef npy_intp maybelong;
 #define MAXDIM NPY_MAXDIMS
 
 #define HAS_UINT64 1
@@ -179,7 +178,7 @@
 static int
 NA_ByteOrder(void)
 {
-        unsigned long byteorder_test;
+    unsigned int byteorder_test;
         byteorder_test = 1;
         if (*((char *) &byteorder_test))
                 return NUM_LITTLE_ENDIAN;
@@ -189,9 +188,10 @@
 
 /* ignores bytestride */
 static PyArrayObject *
-NA_NewAllFromBuffer(int ndim, maybelong *shape, NumarrayType type,
-                                        PyObject *bufferObject, maybelong byteoffset, maybelong bytestride,
-                                        int byteorder, int aligned, int writeable)
+NA_NewAllFromBuffer(int ndim, npy_intp *shape, NumarrayType type,
+                    PyObject *bufferObject, npy_intp byteoffset,
+                    npy_intp bytestride, int byteorder, int aligned,
+                    int writeable)
 {
         PyArrayObject *self = NULL;
         PyArray_Descr *dtype;
@@ -240,18 +240,16 @@
 }
 
 static PyArrayObject *
-NA_NewAll(int ndim, maybelong *shape, NumarrayType type,
-                    void *buffer, maybelong byteoffset, maybelong bytestride,
+NA_NewAll(int ndim, npy_intp *shape, NumarrayType type,
+                    void *buffer, npy_intp byteoffset, npy_intp bytestride,
                     int byteorder, int aligned, int writeable)
 {
-        PyArrayObject *result = NA_NewAllFromBuffer(
-                                                                                                ndim, shape, type, Py_None,
+    PyArrayObject *result = NA_NewAllFromBuffer(ndim, shape, type, Py_None,
                                                                                                 byteoffset, bytestride,
                                                                                                 byteorder, aligned, writeable);
         if (result) {
                 if (!PyArray_Check((PyObject *) result)) {
-                        PyErr_Format( PyExc_TypeError,
-                                                    "NA_NewAll: non-NumArray result");
+            PyErr_Format(PyExc_TypeError, "NA_NewAll: non-NumArray result");
                         result = NULL;
                 } else {
                         if (buffer) {
@@ -269,7 +267,7 @@
 Call with buffer==NULL to allocate storage.
 */
 static PyArrayObject *
-NA_NewArray(void *buffer, NumarrayType type, int ndim, maybelong *shape)
+NA_NewArray(void *buffer, NumarrayType type, int ndim, npy_intp *shape)
 {
         return (PyArrayObject *) NA_NewAll(ndim, shape, type, buffer, 0, 0,
                                                                              NA_ByteOrder(), 1, 1);

Modified: trunk/scipy/ndimage/src/ni_filters.c
===================================================================
--- trunk/scipy/ndimage/src/ni_filters.c	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_filters.c	2010-09-12 00:57:31 UTC (rev 6747)
@@ -38,10 +38,10 @@
 
 int NI_Correlate1D(PyArrayObject *input, PyArrayObject *weights,
                                      int axis, PyArrayObject *output, NI_ExtendMode mode,
-                                     double cval, maybelong origin)
+                   double cval, npy_intp origin)
 {
-    int symmetric = 0, ii, jj, more;
-    maybelong ll, lines, length, size1, size2, filter_size;
+    int symmetric = 0, more;
+    npy_intp ii, jj, ll, lines, length, size1, size2, filter_size;
     double *ibuffer = NULL, *obuffer = NULL;
     Float64 *fw;
     NI_LineBuffer iline_buffer, oline_buffer;
@@ -133,7 +133,7 @@
                                                          _cvalue, _type, _res, _mv)             \
 case t ## _type:                                                    \
 {                                                                   \
-    maybelong _ii, _offset;                                           \
+    npy_intp _ii, _offset;                                            \
     for(_ii = 0; _ii < _filter_size; _ii++) {                         \
         _offset = _offsets[_ii];                                        \
         if (_offset == _mv)                                             \
@@ -151,11 +151,11 @@
 
 int NI_Correlate(PyArrayObject* input, PyArrayObject* weights,
                                                 PyArrayObject* output, NI_ExtendMode mode,
-                                                double cvalue, maybelong *origins)
+                 double cvalue, npy_intp *origins)
 {
     Bool *pf = NULL;
-    maybelong fsize, jj, kk, filter_size = 0, border_flag_value;
-    maybelong *offsets = NULL, *oo, size;
+    npy_intp fsize, jj, kk, filter_size = 0, border_flag_value;
+    npy_intp *offsets = NULL, *oo, size;
     NI_FilterIterator fi;
     NI_Iterator ii, io;
     char *pi, *po;
@@ -274,11 +274,11 @@
 }
 
 int
-NI_UniformFilter1D(PyArrayObject *input, long filter_size,
+NI_UniformFilter1D(PyArrayObject *input, npy_intp filter_size,
                                      int axis, PyArrayObject *output, NI_ExtendMode mode,
-                                     double cval, long origin)
+                   double cval, npy_intp origin)
 {
-    maybelong lines, kk, ll, length, size1, size2;
+    npy_intp lines, kk, ll, length, size1, size2;
     int more;
     double *ibuffer = NULL, *obuffer = NULL;
     NI_LineBuffer iline_buffer, oline_buffer;
@@ -336,11 +336,11 @@
 }
 
 int
-NI_MinOrMaxFilter1D(PyArrayObject *input, long filter_size,
+NI_MinOrMaxFilter1D(PyArrayObject *input, npy_intp filter_size,
                                         int axis, PyArrayObject *output, NI_ExtendMode mode,
-                                        double cval, long origin, int minimum)
+                    double cval, npy_intp origin, int minimum)
 {
-    maybelong lines, kk, jj, ll, length, size1, size2;
+    npy_intp lines, kk, jj, ll, length, size1, size2;
     int more;
     double *ibuffer = NULL, *obuffer = NULL;
     NI_LineBuffer iline_buffer, oline_buffer;
@@ -405,7 +405,7 @@
                                                             _type, _minimum, _res, _mv, _ss)    \
 case t ## _type:                                                  \
 {                                                                 \
-    maybelong _ii, _oo = *_offsets;                                 \
+    npy_intp _ii, _oo = *_offsets;                                \
     _type _cv = (_type)_cval, _tmp;                                 \
     _res = _oo == _mv ? _cv : *(_type*)(_pi + _oo);                 \
     if (_ss)                                                        \
@@ -428,11 +428,12 @@
 
 int NI_MinOrMaxFilter(PyArrayObject* input, PyArrayObject* footprint,
                 PyArrayObject* structure, PyArrayObject* output,
-                NI_ExtendMode mode, double cvalue, maybelong *origins, int minimum)
+                      NI_ExtendMode mode, double cvalue, npy_intp *origins,
+                      int minimum)
 {
     Bool *pf = NULL;
-    maybelong fsize, jj, kk, filter_size = 0, border_flag_value;
-    maybelong *offsets = NULL, *oo, size;
+    npy_intp fsize, jj, kk, filter_size = 0, border_flag_value;
+    npy_intp *offsets = NULL, *oo, size;
     NI_FilterIterator fi;
     NI_Iterator ii, io;
     char *pi, *po;
@@ -581,9 +582,9 @@
                                                 _rank, _buffer, _res, _mv)                 \
 case t ## _type:                                                   \
 {                                                                  \
-    maybelong _ii;                                                   \
+    npy_intp _ii;                                                  \
     for(_ii = 0; _ii < _filter_size; _ii++) {                        \
-        maybelong _offset = _offsets[_ii];                             \
+        npy_intp _offset = _offsets[_ii];                          \
         if (_offset == _mv)                                            \
             _buffer[_ii] = (_type)_cval;                                 \
         else                                                           \
@@ -595,10 +596,10 @@
 
 int NI_RankFilter(PyArrayObject* input, int rank,
                                     PyArrayObject* footprint, PyArrayObject* output,
-                                    NI_ExtendMode mode, double cvalue, maybelong *origins)
+                  NI_ExtendMode mode, double cvalue, npy_intp *origins)
 {
-    maybelong fsize, jj, filter_size = 0, border_flag_value;
-    maybelong *offsets = NULL, *oo, size;
+    npy_intp fsize, jj, filter_size = 0, border_flag_value;
+    npy_intp *offsets = NULL, *oo, size;
     NI_FilterIterator fi;
     NI_Iterator ii, io;
     char *pi, *po;
@@ -704,12 +705,12 @@
 }
 
 int NI_GenericFilter1D(PyArrayObject *input,
-                int (*function)(double*, maybelong, double*, maybelong, void*),
-                void* data, long filter_size, int axis, PyArrayObject *output,
-                NI_ExtendMode mode, double cval, long origin)
+            int (*function)(double*, npy_intp, double*, npy_intp, void*),
+            void* data, npy_intp filter_size, int axis, PyArrayObject *output,
+            NI_ExtendMode mode, double cval, npy_intp origin)
 {
     int more;
-    maybelong ii, lines, length, size1, size2;
+    npy_intp ii, lines, length, size1, size2;
     double *ibuffer = NULL, *obuffer = NULL;
     NI_LineBuffer iline_buffer, oline_buffer;
 
@@ -761,7 +762,7 @@
                                                     _res, _mv, _function, _data, _buffer)        \
 case t ## _type:                                                       \
 {                                                                      \
-    maybelong _ii, _offset;                                              \
+    npy_intp _ii, _offset;                                             \
     for(_ii = 0; _ii < _filter_size; _ii++) {                            \
         _offset = _offsets[_ii];                                           \
         if (_offset == _mv)                                                \
@@ -780,13 +781,13 @@
 
 
 int NI_GenericFilter(PyArrayObject* input,
-            int (*function)(double*, maybelong, double*, void*), void *data,
+            int (*function)(double*, npy_intp, double*, void*), void *data,
             PyArrayObject* footprint, PyArrayObject* output,
-            NI_ExtendMode mode, double cvalue, maybelong *origins)
+            NI_ExtendMode mode, double cvalue, npy_intp *origins)
 {
     Bool *pf = NULL;
-    maybelong fsize, jj, filter_size = 0, border_flag_value;
-    maybelong *offsets = NULL, *oo, size;
+    npy_intp fsize, jj, filter_size = 0, border_flag_value;
+    npy_intp *offsets = NULL, *oo, size;
     NI_FilterIterator fi;
     NI_Iterator ii, io;
     char *pi, *po;

Modified: trunk/scipy/ndimage/src/ni_filters.h
===================================================================
--- trunk/scipy/ndimage/src/ni_filters.h	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_filters.h	2010-09-12 00:57:31 UTC (rev 6747)
@@ -33,22 +33,22 @@
 #define NI_FILTERS_H
 
 int NI_Correlate1D(PyArrayObject*, PyArrayObject*, int, PyArrayObject*,
-                                     NI_ExtendMode, double, maybelong);
+                   NI_ExtendMode, double, npy_intp);
 int NI_Correlate(PyArrayObject*, PyArrayObject*, PyArrayObject*,
-                                 NI_ExtendMode, double, maybelong*);
-int NI_UniformFilter1D(PyArrayObject*, long, int, PyArrayObject*,
-                                             NI_ExtendMode, double, long);
-int NI_MinOrMaxFilter1D(PyArrayObject*, long, int, PyArrayObject*,
-                                                NI_ExtendMode, double, long, int);
+                 NI_ExtendMode, double, npy_intp*);
+int NI_UniformFilter1D(PyArrayObject*, npy_intp, int, PyArrayObject*,
+                       NI_ExtendMode, double, npy_intp);
+int NI_MinOrMaxFilter1D(PyArrayObject*, npy_intp, int, PyArrayObject*,
+                        NI_ExtendMode, double, npy_intp, int);
 int NI_MinOrMaxFilter(PyArrayObject*, PyArrayObject*, PyArrayObject*,
-                                            PyArrayObject*, NI_ExtendMode, double, maybelong*,
+                      PyArrayObject*, NI_ExtendMode, double, npy_intp*,
                                             int);
 int NI_RankFilter(PyArrayObject*, int, PyArrayObject*, PyArrayObject*,
-                                    NI_ExtendMode, double, maybelong*);
-int NI_GenericFilter1D(PyArrayObject*, int (*)(double*, maybelong, 
-                                             double*, maybelong, void*), void*, long, int,
-                                             PyArrayObject*, NI_ExtendMode, double, long);
-int NI_GenericFilter(PyArrayObject*, int (*)(double*, maybelong, double*,
+                                    NI_ExtendMode, double, npy_intp*);
+int NI_GenericFilter1D(PyArrayObject*, int (*)(double*, npy_intp,
+                       double*, npy_intp, void*), void*, npy_intp, int,
+                       PyArrayObject*, NI_ExtendMode, double, npy_intp);
+int NI_GenericFilter(PyArrayObject*, int (*)(double*, npy_intp, double*,
                                          void*), void*, PyArrayObject*, PyArrayObject*,
-                                         NI_ExtendMode, double, maybelong*);
+                     NI_ExtendMode, double, npy_intp*);
 #endif

Modified: trunk/scipy/ndimage/src/ni_fourier.c
===================================================================
--- trunk/scipy/ndimage/src/ni_fourier.c	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_fourier.c	2010-09-12 00:57:31 UTC (rev 6747)
@@ -181,12 +181,13 @@
     break;
 
 int NI_FourierFilter(PyArrayObject *input, PyArrayObject* parameter_array,
-                        maybelong n, int axis, PyArrayObject* output, int filter_type)
+                     npy_intp n, int axis, PyArrayObject* output,
+                     int filter_type)
 {
     NI_Iterator ii, io;
     char *pi, *po;
     double *parameters = NULL, **params = NULL;
-    maybelong kk, hh, size;
+    npy_intp kk, hh, size;
     Float64 *iparameters = (void *)PyArray_DATA(parameter_array);
     int ll;
 
@@ -432,12 +433,12 @@
     break;
 
 int NI_FourierShift(PyArrayObject *input, PyArrayObject* shift_array,
-            maybelong n, int axis, PyArrayObject* output)
+            npy_intp n, int axis, PyArrayObject* output)
 {
     NI_Iterator ii, io;
     char *pi, *po;
     double *shifts = NULL, **params = NULL;
-    maybelong kk, hh, size;
+    npy_intp kk, hh, size;
     Float64 *ishifts = (void *)PyArray_DATA(shift_array);
     int ll;
 

Modified: trunk/scipy/ndimage/src/ni_fourier.h
===================================================================
--- trunk/scipy/ndimage/src/ni_fourier.h	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_fourier.h	2010-09-12 00:57:31 UTC (rev 6747)
@@ -32,9 +32,9 @@
 #ifndef NI_FOURIER_H
 #define NI_FOURIER_H
 
-int NI_FourierFilter(PyArrayObject*, PyArrayObject*, maybelong, int,
+int NI_FourierFilter(PyArrayObject*, PyArrayObject*, npy_intp, int,
                                          PyArrayObject*, int);
-int NI_FourierShift(PyArrayObject*, PyArrayObject*, maybelong, int,
+int NI_FourierShift(PyArrayObject*, PyArrayObject*, npy_intp, int,
                                         PyArrayObject*);
 
 #endif

Modified: trunk/scipy/ndimage/src/ni_interpolation.c
===================================================================
--- trunk/scipy/ndimage/src/ni_interpolation.c	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_interpolation.c	2010-09-12 00:57:31 UTC (rev 6747)
@@ -113,7 +113,7 @@
 /* map a coordinate outside the borders, according to the requested
      boundary condition: */
 static double
-map_coordinate(double in, maybelong len, int mode)
+map_coordinate(double in, npy_intp len, int mode)
 {
     if (in < 0) {
         switch (mode) {
@@ -121,8 +121,8 @@
             if (len <= 1) {
                 in = 0;
             } else {
-                maybelong sz2 = 2 * len - 2;
-                in = sz2 * (maybelong)(-in / sz2) + in;
+                npy_intp sz2 = 2 * len - 2;
+                in = sz2 * (npy_intp)(-in / sz2) + in;
                 in = in <= 1 - len ? in + sz2 : -in;
             }
             break;
@@ -130,9 +130,9 @@
             if (len <= 1) {
                 in = 0;
             } else {
-                maybelong sz2 = 2 * len;
+                npy_intp sz2 = 2 * len;
                 if (in < -sz2)
-                    in = sz2 * (maybelong)(-in / sz2) + in;
+                    in = sz2 * (npy_intp)(-in / sz2) + in;
                 in = in < -len ? in + sz2 : -in - 1;
             }
             break;
@@ -140,10 +140,10 @@
             if (len <= 1) {
                 in = 0;
             } else {
-                maybelong sz = len - 1;
+                npy_intp sz = len - 1;
                 // Integer division of -in/sz gives (-in mod sz)
                 // Note that 'in' is negative
-                in += sz * ((maybelong)(-in / sz) + 1);
+                in += sz * ((npy_intp)(-in / sz) + 1);
             }
             break;
         case NI_EXTEND_NEAREST:
@@ -159,8 +159,8 @@
             if (len <= 1) {
                 in = 0;
             } else {
-                maybelong sz2 = 2 * len - 2;
-                in -= sz2 * (maybelong)(in / sz2);
+                npy_intp sz2 = 2 * len - 2;
+                in -= sz2 * (npy_intp)(in / sz2);
                 if (in >= len)
                     in = sz2 - in;
             }
@@ -169,8 +169,8 @@
             if (len <= 1) {
                 in = 0;
             } else {
-                maybelong sz2 = 2 * len;
-                in -= sz2 * (maybelong)(in / sz2);
+                npy_intp sz2 = 2 * len;
+                in -= sz2 * (npy_intp)(in / sz2);
                 if (in >= len)
                     in = sz2 - in - 1;
             }
@@ -179,8 +179,8 @@
             if (len <= 1) {
                 in = 0;
             } else {
-                maybelong sz = len - 1;
-                in -= sz * (maybelong)(in / sz);
+                npy_intp sz = len - 1;
+                in -= sz * (npy_intp)(in / sz);
             }
             break;
         case NI_EXTEND_NEAREST:
@@ -203,7 +203,7 @@
                                             PyArrayObject *output)
 {
     int hh, npoles = 0, more;
-    maybelong kk, ll, lines, len;
+    npy_intp kk, ll, lines, len;
     double *buffer = NULL, weight, pole[2];
     NI_LineBuffer iline_buffer, oline_buffer;
 
@@ -345,18 +345,18 @@
     break;
 
 int
-NI_GeometricTransform(PyArrayObject *input, int (*map)(maybelong*, double*,
+NI_GeometricTransform(PyArrayObject *input, int (*map)(npy_intp*, double*,
                 int, int, void*), void* map_data, PyArrayObject* matrix_ar,
                 PyArrayObject* shift_ar, PyArrayObject *coordinates,
                 PyArrayObject *output, int order, int mode, double cval)
 {
     char *po, *pi, *pc = NULL;
-    maybelong **edge_offsets = NULL, **data_offsets = NULL, filter_size;
-    maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL;
-    maybelong cstride = 0, kk, hh, ll, jj, *idxs = NULL;
-    maybelong size;
+    npy_intp **edge_offsets = NULL, **data_offsets = NULL, filter_size;
+    npy_intp ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL;
+    npy_intp cstride = 0, kk, hh, ll, jj, *idxs = NULL;
+    npy_intp size;
     double **splvals = NULL, icoor[MAXDIM];
-    double idimensions[MAXDIM], istrides[MAXDIM];
+    npy_intp idimensions[MAXDIM], istrides[MAXDIM];
     NI_Iterator io, ic;
     Float64 *matrix = matrix_ar ? (Float64*)PyArray_DATA(matrix_ar) : NULL;
     Float64 *shift = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL;
@@ -381,8 +381,8 @@
     }
 
     /* offsets used at the borders: */
-    edge_offsets = (maybelong**)malloc(irank * sizeof(maybelong*));
-    data_offsets = (maybelong**)malloc(irank * sizeof(maybelong*));
+    edge_offsets = (npy_intp**)malloc(irank * sizeof(npy_intp*));
+    data_offsets = (npy_intp**)malloc(irank * sizeof(npy_intp*));
     if (!edge_offsets || !data_offsets) {
         PyErr_NoMemory();
         goto exit;
@@ -390,7 +390,7 @@
     for(jj = 0; jj < irank; jj++)
         data_offsets[jj] = NULL;
     for(jj = 0; jj < irank; jj++) {
-        data_offsets[jj] = (maybelong*)malloc((order + 1) * sizeof(maybelong));
+        data_offsets[jj] = (npy_intp*)malloc((order + 1) * sizeof(npy_intp));
         if (!data_offsets[jj]) {
             PyErr_NoMemory();
             goto exit;
@@ -415,7 +415,7 @@
     filter_size = 1;
     for(jj = 0; jj < irank; jj++)
         filter_size *= order + 1;
-    idxs = (maybelong*)malloc(filter_size * sizeof(idxs));
+    idxs = (npy_intp*)malloc(filter_size * sizeof(idxs));
     if (!idxs) {
         PyErr_NoMemory();
         goto exit;
@@ -430,9 +430,9 @@
     po = (void *)PyArray_DATA(output);
 
     /* make a table of all possible coordinates within the spline filter: */
-    fcoordinates = (maybelong*)malloc(irank * filter_size * sizeof(maybelong));
+    fcoordinates = (npy_intp*)malloc(irank * filter_size * sizeof(npy_intp));
     /* make a table of all offsets within the spline filter: */
-    foffsets = (maybelong*)malloc(filter_size * sizeof(maybelong));
+    foffsets = (npy_intp*)malloc(filter_size * sizeof(npy_intp));
     if (!fcoordinates || !foffsets) {
         PyErr_NoMemory();
         goto exit;
@@ -552,7 +552,7 @@
         }
 
         if (!constant) {
-            maybelong *ff = fcoordinates;
+            npy_intp *ff = fcoordinates;
             for(hh = 0; hh < filter_size; hh++) {
                 int idx = 0;
                 if (edge) {
@@ -571,7 +571,7 @@
             }
         }
         if (!constant) {
-            maybelong *ff = fcoordinates;
+            npy_intp *ff = fcoordinates;
             t = 0.0;
             for(hh = 0; hh < filter_size; hh++) {
                 double coeff = 0.0;
@@ -590,7 +590,8 @@
                     CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32);
                     CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64);
                 default:
-                    PyErr_SetString(PyExc_RuntimeError, "data type not supported");
+                    PyErr_SetString(PyExc_RuntimeError,
+                                                    "data type not supported");
                     goto exit;
                 }
                 /* calculate the interpolated value: */
@@ -657,11 +658,11 @@
                                  int order, int mode, double cval)
 {
     char *po, *pi;
-    maybelong **zeros = NULL, **offsets = NULL, ***edge_offsets = NULL;
-    maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL;
-    maybelong jj, hh, kk, filter_size, odimensions[MAXDIM];
-    maybelong idimensions[MAXDIM], istrides[MAXDIM], *idxs = NULL;
-    maybelong size;
+    npy_intp **zeros = NULL, **offsets = NULL, ***edge_offsets = NULL;
+    npy_intp ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL;
+    npy_intp jj, hh, kk, filter_size, odimensions[MAXDIM];
+    npy_intp idimensions[MAXDIM], istrides[MAXDIM], *idxs = NULL;
+    npy_intp size;
     double ***splvals = NULL;
     NI_Iterator io;
     Float64 *zooms = zoom_ar ? (Float64*)PyArray_DATA(zoom_ar) : NULL;
@@ -677,7 +678,7 @@
 
     /* if the mode is 'constant' we need some temps later: */
     if (mode == NI_EXTEND_CONSTANT) {
-        zeros = (maybelong**)malloc(rank * sizeof(maybelong*));
+        zeros = (npy_intp**)malloc(rank * sizeof(npy_intp*));
         if (!zeros) {
             PyErr_NoMemory();
             goto exit;
@@ -685,7 +686,7 @@
         for(jj = 0; jj < rank; jj++)
             zeros[jj] = NULL;
         for(jj = 0; jj < rank; jj++) {
-            zeros[jj] = (maybelong*)malloc(odimensions[jj] * sizeof(maybelong));
+            zeros[jj] = (npy_intp*)malloc(odimensions[jj] * sizeof(npy_intp));
             if(!zeros[jj]) {
                 PyErr_NoMemory();
                 goto exit;
@@ -694,11 +695,11 @@
     }
 
     /* store offsets, along each axis: */
-    offsets = (maybelong**)malloc(rank * sizeof(maybelong*));
+    offsets = (npy_intp**)malloc(rank * sizeof(npy_intp*));
     /* store spline coefficients, along each axis: */
     splvals = (double***)malloc(rank * sizeof(double**));
     /* store offsets at all edges: */
-    edge_offsets = (maybelong***)malloc(rank * sizeof(maybelong**));
+    edge_offsets = (npy_intp***)malloc(rank * sizeof(npy_intp**));
     if (!offsets || !splvals || !edge_offsets) {
         PyErr_NoMemory();
         goto exit;
@@ -709,9 +710,9 @@
         edge_offsets[jj] = NULL;
     }
     for(jj = 0; jj < rank; jj++) {
-        offsets[jj] = (maybelong*)malloc(odimensions[jj] * sizeof(maybelong));
+        offsets[jj] = (npy_intp*)malloc(odimensions[jj] * sizeof(npy_intp));
         splvals[jj] = (double**)malloc(odimensions[jj] * sizeof(double*));
-        edge_offsets[jj] = (maybelong**)malloc(odimensions[jj] * sizeof(maybelong*));
+        edge_offsets[jj] = (npy_intp**)malloc(odimensions[jj] * sizeof(npy_intp*));
         if (!offsets[jj] || !splvals[jj] || !edge_offsets[jj]) {
             PyErr_NoMemory();
             goto exit;
@@ -747,7 +748,7 @@
                 }
                 offsets[jj][kk] = istrides[jj] * start;
                 if (start < 0 || start + order >= idimensions[jj]) {
-                    edge_offsets[jj][kk] = (maybelong*)malloc((order + 1) * sizeof(maybelong));
+                    edge_offsets[jj][kk] = (npy_intp*)malloc((order + 1) * sizeof(npy_intp));
                     if (!edge_offsets[jj][kk]) {
                         PyErr_NoMemory();
                         goto exit;
@@ -788,7 +789,7 @@
     filter_size = 1;
     for(jj = 0; jj < rank; jj++)
         filter_size *= order + 1;
-    idxs = (maybelong*)malloc(filter_size * sizeof(idxs));
+    idxs = (npy_intp*)malloc(filter_size * sizeof(idxs));
     if (!idxs) {
         PyErr_NoMemory();
         goto exit;
@@ -801,8 +802,8 @@
     po = (void *)PyArray_DATA(output);
 
     /* store all coordinates and offsets with filter: */
-    fcoordinates = (maybelong*)malloc(rank * filter_size * sizeof(maybelong));
-    foffsets = (maybelong*)malloc(filter_size * sizeof(maybelong));
+    fcoordinates = (npy_intp*)malloc(rank * filter_size * sizeof(npy_intp));
+    foffsets = (npy_intp*)malloc(filter_size * sizeof(npy_intp));
     if (!fcoordinates || !foffsets) {
         PyErr_NoMemory();
         goto exit;
@@ -845,7 +846,7 @@
         }
 
         if (!zero) {
-            maybelong *ff = fcoordinates;
+            npy_intp *ff = fcoordinates;
             for(hh = 0; hh < filter_size; hh++) {
                 int idx = 0;
                 if (edge) {
@@ -866,7 +867,7 @@
             }
         }
         if (!zero) {
-            maybelong *ff = fcoordinates;
+            npy_intp *ff = fcoordinates;
             t = 0.0;
             for(hh = 0; hh < filter_size; hh++) {
                 double coeff = 0.0;
@@ -885,7 +886,8 @@
                     CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32);
                     CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64);
                 default:
-                    PyErr_SetString(PyExc_RuntimeError, "data type not supported");
+                    PyErr_SetString(PyExc_RuntimeError,
+                                                    "data type not supported");
                     goto exit;
                 }
                 /* calculate interpolated value: */

Modified: trunk/scipy/ndimage/src/ni_interpolation.h
===================================================================
--- trunk/scipy/ndimage/src/ni_interpolation.h	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_interpolation.h	2010-09-12 00:57:31 UTC (rev 6747)
@@ -33,7 +33,7 @@
 #define NI_INTERPOLATION_H
 
 int NI_SplineFilter1D(PyArrayObject*, int, int, PyArrayObject*);
-int NI_GeometricTransform(PyArrayObject*, int (*)(maybelong*, double*, int, int,
+int NI_GeometricTransform(PyArrayObject*, int (*)(npy_intp*, double*, int, int,
                                                     void*), void*, PyArrayObject*, PyArrayObject*,
                                                     PyArrayObject*, PyArrayObject*, int, int,
                                                     double);

Modified: trunk/scipy/ndimage/src/ni_measure.c
===================================================================
--- trunk/scipy/ndimage/src/ni_measure.c	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_measure.c	2010-09-12 00:57:31 UTC (rev 6747)
@@ -47,11 +47,11 @@
     break
 
 int NI_Label(PyArrayObject* input, PyArrayObject* strct,
-                         maybelong *max_label, PyArrayObject* output)
+                         npy_intp *max_label, PyArrayObject* output)
 {
     int kk;
-    maybelong jj, ll, ssize, size, filter_size, *offsets = NULL;
-    maybelong mask_value, *oo;
+    npy_intp jj, ll, ssize, size, filter_size, *offsets = NULL;
+    npy_intp mask_value, *oo;
     Bool *ps, *footprint = NULL;
     char *pi, *po;
     Int32 index = 0, *index_map = NULL;
@@ -193,8 +193,8 @@
                 index_map[idx2] = idx1;
             } else {
                 /* idx2 was already mapped, therefore we find what it was
-                     mapped to and change the current pair to the result of that
-                     and idx1. Since the pair is not destroyed, it will be
+                     mapped to and change the current pair to the result of
+                     that and idx1. Since the pair is not destroyed, it will be
                      re-processed with the adapted values.  */
                 idx2 = index_map[idx2];
                 /* keep the pairs ordered: */
@@ -256,19 +256,19 @@
 case t ## _type:                                                  \
 {                                                                 \
     int _kk;                                                        \
-    maybelong _sindex = *(_type*)_pi - 1;                           \
+    npy_intp _sindex = *(_type*)_pi - 1;                            \
     if (_sindex >= 0 && _sindex < _max_label) {                     \
         if (_rank > 0) {                                              \
             _sindex *= 2 * _rank;                                       \
             if (_regions[_sindex] < 0) {                                \
                 for(_kk = 0; _kk < _rank; _kk++) {                        \
-                    maybelong _cc = _ii.coordinates[_kk];                   \
+                    npy_intp _cc = _ii.coordinates[_kk];            \
                     _regions[_sindex + _kk] = _cc;                          \
                     _regions[_sindex + _kk + _rank] = _cc + 1;              \
                 }                                                         \
             } else {                                                    \
                 for(_kk = 0; _kk < _rank; _kk++) {                        \
-                    maybelong _cc = _ii.coordinates[_kk];                   \
+                    npy_intp _cc = _ii.coordinates[_kk];            \
                     if (_cc < _regions[_sindex + _kk])                      \
                         _regions[_sindex + _kk] = _cc;                        \
                     if (_cc + 1 > _regions[_sindex + _kk + _rank])          \
@@ -282,11 +282,11 @@
 }                                                                 \
 break
 
-int NI_FindObjects(PyArrayObject* input, maybelong max_label,
-                                     maybelong* regions)
+int NI_FindObjects(PyArrayObject* input, npy_intp max_label,
+                                     npy_intp* regions)
 {
     int kk;
-    maybelong size, jj;
+    npy_intp size, jj;
     NI_Iterator ii;
     char *pi;
 
@@ -378,7 +378,8 @@
         _v = *(Float64*)_pi;                                              \
         break;                                                            \
     default:                                                            \
-            PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \
+            PyErr_SetString(PyExc_RuntimeError,                       \
+                                         "data type not supported");  \
             return 0;                                                       \
     }                                                                   \
 }
@@ -417,7 +418,8 @@
         _v = *(Float64*)_pi;                                              \
         break;                                                            \
     default:                                                            \
-            PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \
+            PyErr_SetString(PyExc_RuntimeError,                       \
+                                        "data type not supported");   \
             return 0;                                                       \
     }                                                                   \
 }
@@ -463,7 +465,8 @@
             _label = *(Float64*)_pm;                                        \
             break;                                                          \
         default:                                                          \
-            PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \
+            PyErr_SetString(PyExc_RuntimeError,                       \
+                                        "data type not supported");   \
             return 0;                                                       \
         }                                                                 \
     }                                                                   \
@@ -504,7 +507,8 @@
             _label = *(Float64*)_pm;                                        \
             break;                                                          \
         default:                                                          \
-            PyErr_SetString(PyExc_RuntimeError, "data type not supported"); \
+            PyErr_SetString(PyExc_RuntimeError,                       \
+                                        "data type not supported");   \
             return 0;                                                       \
         }                                                                 \
     }                                                                   \
@@ -512,13 +516,13 @@
 #endif
 
 int NI_Statistics(PyArrayObject *input, PyArrayObject *labels,
-    maybelong min_label, maybelong max_label, maybelong *indices,
-    maybelong n_results, double *sum, maybelong *total, double *variance,
-    double *minimum, double *maximum, maybelong* min_pos, maybelong* max_pos)
+    npy_intp min_label, npy_intp max_label, npy_intp *indices,
+    npy_intp n_results, double *sum, npy_intp *total, double *variance,
+    double *minimum, double *maximum, npy_intp* min_pos, npy_intp* max_pos)
 {
     char *pi = NULL, *pm = NULL;
     NI_Iterator ii, mi;
-    maybelong jj, size, idx = 0, label = 1, doit = 1;
+    npy_intp jj, size, idx = 0, label = 1, doit = 1;
     int qq;
 
     /* input iterator: */
@@ -650,12 +654,12 @@
 
 
 int NI_CenterOfMass(PyArrayObject *input, PyArrayObject *labels,
-                            maybelong min_label, maybelong max_label, maybelong *indices,
-                            maybelong n_results, double *center_of_mass)
+                    npy_intp min_label, npy_intp max_label, npy_intp *indices,
+                    npy_intp n_results, double *center_of_mass)
 {
     char *pi = NULL, *pm = NULL;
     NI_Iterator ii, mi;
-    maybelong jj, kk, size, idx = 0, label = 1, doit = 1;
+    npy_intp jj, kk, size, idx = 0, label = 1, doit = 1;
     double *sum = NULL;
     int qq;
 
@@ -720,13 +724,13 @@
 
 
 int NI_Histogram(PyArrayObject *input, PyArrayObject *labels,
-                            maybelong min_label, maybelong max_label, maybelong *indices,
-                            maybelong n_results, PyArrayObject **histograms,
-                            double min, double max, maybelong nbins)
+                 npy_intp min_label, npy_intp max_label, npy_intp *indices,
+                 npy_intp n_results, PyArrayObject **histograms,
+                 double min, double max, npy_intp nbins)
 {
     char *pi = NULL, *pm = NULL;
     NI_Iterator ii, mi;
-    maybelong jj, kk, size, idx = 0, label = 1, doit = 1;
+    npy_intp jj, kk, size, idx = 0, label = 1, doit = 1;
     Int32 **ph = NULL;
     double bsize;
     int qq;
@@ -797,7 +801,7 @@
         _out = _index * sizeof(_type);                                \
     } else {                                                        \
         int _qq;                                                      \
-        maybelong _cc, _idx = _index;                                 \
+        npy_intp _cc, _idx = _index;                              \
         _out = 0;                                                     \
         for (_qq = 0; _qq < _rank; _qq++) {                           \
             _cc = _idx / _c_strides[_qq];                               \
@@ -854,7 +858,7 @@
 #define WS_MAXDIM 7
 
 typedef struct {
-    maybelong index;
+    npy_intp index;
     COST_TYPE cost;
     void *next, *prev;
     DONE_TYPE done;
@@ -865,9 +869,9 @@
 {
     char *pl, *pm, *pi;
     int ll;
-    maybelong size, jj, hh, kk, maxval;
-    maybelong strides[WS_MAXDIM], coordinates[WS_MAXDIM];
-    maybelong *nstrides = NULL, nneigh, ssize;
+    npy_intp size, jj, hh, kk, maxval;
+    npy_intp strides[WS_MAXDIM], coordinates[WS_MAXDIM];
+    npy_intp *nstrides = NULL, nneigh, ssize;
     int i_contiguous, o_contiguous;
     NI_WatershedElement *temp = NULL, **first = NULL, **last = NULL;
     Bool *ps = NULL;
@@ -978,8 +982,8 @@
                 last[0] = first[0];
             } else {
                 if (label > 0) {
-                    /* object markers are enqueued at the beginning, so they are
-                         processed first. */
+                    /* object markers are enqueued at the beginning, so they
+                       are processed first. */
                     temp[jj].next = first[0];
                     temp[jj].prev = NULL;
                     first[0]->prev = &(temp[jj]);
@@ -1014,7 +1018,7 @@
     for (kk = 0; kk < ssize; kk++)
         if (ps[kk] && kk != (ssize / 2))
             ++nneigh;
-    nstrides = (maybelong*)malloc(nneigh * sizeof(maybelong));
+    nstrides = (npy_intp*)malloc(nneigh * sizeof(npy_intp));
     if (!nstrides) {
         PyErr_NoMemory();
         goto exit;
@@ -1057,7 +1061,7 @@
             v->done = 1;
             /* Iterate over the neighbors of the element: */
             for(hh = 0; hh < nneigh; hh++) {
-                maybelong v_index = v->index, p_index = v->index, idx, cc;
+                npy_intp v_index = v->index, p_index = v->index, idx, cc;
                 int qq, outside = 0;
                 p_index += nstrides[hh];
                 /* check if the neighbor is within the extent of the array: */

Modified: trunk/scipy/ndimage/src/ni_measure.h
===================================================================
--- trunk/scipy/ndimage/src/ni_measure.h	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_measure.h	2010-09-12 00:57:31 UTC (rev 6747)
@@ -39,19 +39,20 @@
     int start[NI_MAXDIM], end[NI_MAXDIM];
 } NI_ObjectRegion;
 
-int NI_Label(PyArrayObject*, PyArrayObject*, maybelong*, PyArrayObject*);
+int NI_Label(PyArrayObject*, PyArrayObject*, npy_intp*, PyArrayObject*);
 
-int NI_FindObjects(PyArrayObject*, maybelong, maybelong*);
+int NI_FindObjects(PyArrayObject*, npy_intp, npy_intp*);
 
-int NI_CenterOfMass(PyArrayObject*, PyArrayObject*, maybelong, maybelong,
-                                        maybelong*, maybelong, double*);
+int NI_CenterOfMass(PyArrayObject*, PyArrayObject*, npy_intp, npy_intp,
+                    npy_intp*, npy_intp, double*);
 
-int NI_Histogram(PyArrayObject*, PyArrayObject*, maybelong, maybelong, 
-             maybelong*, maybelong,  PyArrayObject**, double, double, maybelong);
+int NI_Histogram(PyArrayObject*, PyArrayObject*, npy_intp, npy_intp,
+                 npy_intp*, npy_intp, PyArrayObject**, double, double,
+                 npy_intp);
 
-int NI_Statistics(PyArrayObject*, PyArrayObject*, maybelong, maybelong,
-                                    maybelong*, maybelong, double*, maybelong*, double*, 
-                                    double*, double*, maybelong*, maybelong*);
+int NI_Statistics(PyArrayObject*, PyArrayObject*, npy_intp, npy_intp,
+                  npy_intp*, npy_intp, double*, npy_intp*, double*,
+                  double*, double*, npy_intp*, npy_intp*);
 
 int NI_WatershedIFT(PyArrayObject*, PyArrayObject*, PyArrayObject*, 
                                         PyArrayObject*);

Modified: trunk/scipy/ndimage/src/ni_morphology.c
===================================================================
--- trunk/scipy/ndimage/src/ni_morphology.c	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_morphology.c	2010-09-12 00:57:31 UTC (rev 6747)
@@ -53,7 +53,7 @@
                                                         _true, _false, _changed)                  \
 case t ## _type:                                                      \
 {                                                                     \
-    maybelong _ii, _oo;                                                 \
+    npy_intp _ii, _oo;                                                  \
     int _in = *(_type*)_pi ? 1 : 0;                                     \
     if (_mv) {                                                          \
         if (_center_is_true && _in == false) {                            \
@@ -86,11 +86,11 @@
 
 int NI_BinaryErosion(PyArrayObject* input, PyArrayObject* strct,
                 PyArrayObject* mask, PyArrayObject* output, int bdr_value,
-                maybelong *origins, int invert, int center_is_true, int* changed,
-                NI_CoordinateList **coordinate_list)
+                     npy_intp *origins, int invert, int center_is_true,
+                     int* changed, NI_CoordinateList **coordinate_list)
 {
-    maybelong struct_size = 0, *offsets = NULL, size, *oo, jj;
-    maybelong ssize, block_size = 0, *current = NULL, border_flag_value;
+    npy_intp struct_size = 0, *offsets = NULL, size, *oo, jj;
+    npy_intp ssize, block_size = 0, *current = NULL, border_flag_value;
     int kk, true, false, msk_value;
     NI_Iterator ii, io, mi;
     NI_FilterIterator fi;
@@ -274,12 +274,12 @@
                                                     _mklist)                                     \
 case t ## _type:                                                       \
 {                                                                      \
-    maybelong _hh, _kk;                                                  \
+    npy_intp _hh, _kk;                                                        \
     for(_hh = 0; _hh < _struct_size; _hh++) {                            \
-        maybelong _to = _offsets[_oo + _hh];                               \
+        npy_intp _to = _offsets[_oo + _hh];                                   \
         if (_to != _bf_value && *(_type*)(_pi + _to) == _true) {           \
             if (_mklist) {                                                   \
-                maybelong *_tc = &(_coordinate_offsets[(_oo + _hh) * _irank]); \
+                npy_intp *_tc = &(_coordinate_offsets[(_oo + _hh) * _irank]); \
                 if (_block2 == NULL || _block2->size == _list2->block_size) {  \
                     _block2 = NI_CoordinateListAddBlock(_list2);                 \
                     _current_coors2 = _block2->coordinates;                      \
@@ -295,13 +295,13 @@
 break
 
 int NI_BinaryErosion2(PyArrayObject* array, PyArrayObject* strct,
-                                            PyArrayObject* mask, int niter, maybelong *origins,
+                      PyArrayObject* mask, int niter, npy_intp *origins,
                                             int invert, NI_CoordinateList **iclist)
 {
-    maybelong struct_size = 0, *offsets = NULL, oo, jj, ssize;
-    maybelong *coordinate_offsets = NULL, size = 0;
-    maybelong *current_coordinates1 = NULL, *current_coordinates2 = NULL;
-    maybelong kk, border_flag_value, current = 0;
+    npy_intp struct_size = 0, *offsets = NULL, oo, jj, ssize;
+    npy_intp *coordinate_offsets = NULL, size = 0;
+    npy_intp *current_coordinates1 = NULL, *current_coordinates2 = NULL;
+    npy_intp kk, border_flag_value, current = 0;
     int true, false;
     NI_Iterator ii, mi;
     NI_FilterIterator fi, ci;
@@ -495,8 +495,8 @@
 #define NI_DISTANCE_CHESSBOARD 3
 
 typedef struct {
-    maybelong *coordinates;
-    maybelong index;
+    npy_intp *coordinates;
+    npy_intp index;
     void *next;
 } NI_BorderElement;
 
@@ -505,7 +505,7 @@
                                                                      PyArrayObject* distances,
                                                                      PyArrayObject* features)
 {
-    maybelong size, jj, min_index = 0;
+    npy_intp size, jj, min_index = 0;
     int kk;
     NI_BorderElement *border_elements = NULL, *temp;
     NI_Iterator ii, di, fi;
@@ -543,7 +543,7 @@
             temp->next = border_elements;
             border_elements = temp;
             temp->index = jj;
-            temp->coordinates = (maybelong*)malloc(input->nd * sizeof(maybelong));
+            temp->coordinates = (npy_intp*)malloc(input->nd * sizeof(npy_intp));
             for(kk = 0; kk < input->nd; kk++)
                     temp->coordinates[kk] = ii.coordinates[kk];
         }
@@ -597,11 +597,11 @@
     case NI_DISTANCE_CHESSBOARD:
         for(jj = 0; jj < size; jj++) {
             if (*(Int8*)pi > 0) {
-                unsigned long distance = ULONG_MAX;
+                unsigned int distance = UINT_MAX;
                 temp = border_elements;
                 while(temp) {
                     unsigned int d = 0;
-                    maybelong t;
+                    npy_intp t;
                     for(kk = 0; kk < input->nd; kk++) {
                         t = ii.coordinates[kk] - temp->coordinates[kk];
                         if (t < 0)
@@ -657,11 +657,12 @@
 
 
 int NI_DistanceTransformOnePass(PyArrayObject *strct,
-                                                PyArrayObject* distances, PyArrayObject *features)
+                                PyArrayObject* distances,
+                                PyArrayObject *features)
 {
     int kk;
-    maybelong jj, ii, ssize, size, filter_size, mask_value, *oo;
-    maybelong *foffsets = NULL, *foo = NULL, *offsets = NULL;
+    npy_intp jj, ii, ssize, size, filter_size, mask_value, *oo;
+    npy_intp *foffsets = NULL, *foo = NULL, *offsets = NULL;
     Bool *ps, *pf = NULL, *footprint = NULL;
     char *pd;
     NI_FilterIterator si, ti;
@@ -704,7 +705,7 @@
         goto exit;
 
     if (features) {
-        maybelong dummy;
+        npy_intp dummy;
         /* initialize point iterator: */
         pf = (void *)PyArray_DATA(features);
         if (!NI_InitPointIterator(features, &fi))
@@ -726,10 +727,10 @@
         Int32 value = *(Int32*)pd;
         if (value != 0) {
             Int32 min = value;
-            maybelong min_offset = 0;
+            npy_intp min_offset = 0;
             /* iterate over structuring element: */
             for(ii = 0; ii < filter_size; ii++) {
-                maybelong offset = oo[ii];
+                npy_intp offset = oo[ii];
                 Int32 tt = -1;
                 if (offset < mask_value)
                     tt = *(Int32*)(pd + offset);
@@ -759,11 +760,11 @@
     return PyErr_Occurred() ? 0 : 1;
 }
 
-static void _VoronoiFT(char *pf, maybelong len, maybelong *coor, int rank,
-                                             int d, maybelong stride, maybelong cstride,
-                                             maybelong **f, maybelong *g, Float64 *sampling)
+static void _VoronoiFT(char *pf, npy_intp len, npy_intp *coor, int rank,
+                       int d, npy_intp stride, npy_intp cstride,
+                       npy_intp **f, npy_intp *g, Float64 *sampling)
 {
-    maybelong l = -1, ii, maxl, idx1, idx2;
+    npy_intp l = -1, ii, maxl, idx1, idx2;
     int jj;
 
     for(ii = 0; ii < len; ii++)
@@ -847,13 +848,13 @@
 
 
 /* Recursive feature transform */
-static void _ComputeFT(char *pi, char *pf, maybelong *ishape,
-                                             maybelong *istrides, maybelong *fstrides, int rank,
-                                             int d, maybelong *coor, maybelong **f, maybelong *g,
+static void _ComputeFT(char *pi, char *pf, npy_intp *ishape,
+                       npy_intp *istrides, npy_intp *fstrides, int rank,
+                       int d, npy_intp *coor, npy_intp **f, npy_intp *g,
                                              PyArrayObject *features, Float64 *sampling)
 {
     int kk;
-    maybelong jj;
+    npy_intp jj;
 
     if (d == 0) {
         char *tf1 = pf;
@@ -876,7 +877,7 @@
     } else {
         UInt32 axes = 0;
         char *tf = pf;
-        maybelong size = 1;
+        npy_intp size = 1;
         NI_Iterator ii;
 
         for(jj = 0; jj < ishape[d]; jj++) {
@@ -915,8 +916,8 @@
                                                                  PyArrayObject* features)
 {
     int ii;
-    maybelong coor[NI_MAXDIM], mx = 0, jj;
-    maybelong *tmp = NULL, **f = NULL, *g = NULL;
+    npy_intp coor[NI_MAXDIM], mx = 0, jj;
+    npy_intp *tmp = NULL, **f = NULL, *g = NULL;
     char *pi, *pf;
     Float64 *sampling = sampling_arr ? ((void *)PyArray_DATA(sampling_arr)) : NULL;
 
@@ -929,9 +930,9 @@
     }
 
     /* Some temporaries */
-    f = (maybelong**)malloc(mx * sizeof(maybelong*));
-    g = (maybelong*)malloc(mx * sizeof(maybelong));
-    tmp = (maybelong*)malloc(mx * input->nd * sizeof(maybelong));
+    f = (npy_intp**)malloc(mx * sizeof(npy_intp*));
+    g = (npy_intp*)malloc(mx * sizeof(npy_intp));
+    tmp = (npy_intp*)malloc(mx * input->nd * sizeof(npy_intp));
     if (!f || !g || !tmp) {
         PyErr_NoMemory();
         goto exit;

Modified: trunk/scipy/ndimage/src/ni_morphology.h
===================================================================
--- trunk/scipy/ndimage/src/ni_morphology.h	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_morphology.h	2010-09-12 00:57:31 UTC (rev 6747)
@@ -33,9 +33,9 @@
 #define NI_MORPHOLOGY_H
 
 int NI_BinaryErosion(PyArrayObject*, PyArrayObject*, PyArrayObject*, 
-         PyArrayObject*, int, maybelong*, int, int, int*, NI_CoordinateList**);
+         PyArrayObject*, int, npy_intp*, int, int, int*, NI_CoordinateList**);
 int NI_BinaryErosion2(PyArrayObject*, PyArrayObject*, PyArrayObject*,
-                                            int, maybelong*, int, NI_CoordinateList**);
+                      int, npy_intp*, int, NI_CoordinateList**);
 int NI_DistanceTransformBruteForce(PyArrayObject*, int, PyArrayObject*,
                                                                      PyArrayObject*, PyArrayObject*);
 int NI_DistanceTransformOnePass(PyArrayObject*, PyArrayObject *,

Modified: trunk/scipy/ndimage/src/ni_support.c
===================================================================
--- trunk/scipy/ndimage/src/ni_support.c	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_support.c	2010-09-12 00:57:31 UTC (rev 6747)
@@ -84,10 +84,10 @@
 /******************************************************************/
 
 /* Allocate line buffer data */
-int NI_AllocateLineBuffer(PyArrayObject* array, int axis, maybelong size1,
-        maybelong size2, maybelong *lines, maybelong max_size, double **buffer)
+int NI_AllocateLineBuffer(PyArrayObject* array, int axis, npy_intp size1,
+        npy_intp size2, npy_intp *lines, npy_intp max_size, double **buffer)
 {
-    maybelong line_size, max_lines;
+    npy_intp line_size, max_lines;
     int ii;
 
     /* the number of lines of the array is an upper limit for the
@@ -120,11 +120,11 @@
 }
 
 /* Initialize a line buffer */
-int NI_InitLineBuffer(PyArrayObject *array, int axis, maybelong size1,
-        maybelong size2, maybelong buffer_lines, double *buffer_data,
+int NI_InitLineBuffer(PyArrayObject *array, int axis, npy_intp size1,
+        npy_intp size2, npy_intp buffer_lines, double *buffer_data,
         NI_ExtendMode extend_mode, double extend_value, NI_LineBuffer *buffer)
 {
-    maybelong line_length = 0, array_lines = 0, size;
+    npy_intp line_length = 0, array_lines = 0, size;
     int ii;
 
     size = 1;
@@ -160,10 +160,10 @@
 }
 
 /* Extend a line in memory to implement boundary conditions: */
-int NI_ExtendLine(double *line, maybelong length, maybelong size1,
-                                maybelong size2, NI_ExtendMode mode, double constant_value)
+int NI_ExtendLine(double *line, npy_intp length, npy_intp size1,
+                  npy_intp size2, NI_ExtendMode mode, double constant_value)
 {
-    maybelong ii, jj, length1, nextend, rextend;
+    npy_intp ii, jj, length1, nextend, rextend;
     double *l1, *l2, *l3, val;
 
     switch (mode) {
@@ -287,7 +287,7 @@
 #define CASE_COPY_DATA_TO_LINE(_pi, _po, _length, _stride, _type) \
 case t ## _type:                                                  \
 {                                                                 \
-    maybelong _ii;                                                  \
+    npy_intp _ii;                                                  \
     for(_ii = 0; _ii < _length; _ii++) {                            \
         _po[_ii] = (double)*(_type*)_pi;                              \
         _pi += _stride;                                               \
@@ -298,11 +298,11 @@
 
 /* Copy a line from an array to a buffer: */
 int NI_ArrayToLineBuffer(NI_LineBuffer *buffer,
-                                                 maybelong *number_of_lines, int *more)
+                         npy_intp *number_of_lines, int *more)
 {
     double *pb = buffer->buffer_data;
     char *pa;
-    maybelong length = buffer->line_length;
+    npy_intp length = buffer->line_length;
 
     pb += buffer->size1;
     *number_of_lines = 0;
@@ -327,7 +327,8 @@
             CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Float32);
             CASE_COPY_DATA_TO_LINE(pa, pb, length, buffer->line_stride, Float64);
         default:
-            PyErr_Format(PyExc_RuntimeError, "array type %d not supported", buffer->array_type);
+            PyErr_Format(PyExc_RuntimeError, "array type %d not supported",
+                         buffer->array_type);
             return 0;
         }
         /* goto next line in the array: */
@@ -352,7 +353,7 @@
 #define CASE_COPY_LINE_TO_DATA(_pi, _po, _length, _stride, _type) \
 case t ## _type:                                                  \
 {                                                                 \
-    maybelong _ii;                                                  \
+    npy_intp _ii;                                                  \
     for(_ii = 0; _ii < _length; _ii++) {                            \
         *(_type*)_po = (_type)_pi[_ii];                               \
         _po += _stride;                                               \
@@ -365,7 +366,7 @@
 {
     double *pb = buffer->buffer_data;
     char *pa;
-    maybelong jj, length = buffer->line_length;
+    npy_intp jj, length = buffer->line_length;
 
     pb += buffer->size1;
     for(jj = 0; jj < buffer->buffer_lines; jj++) {
@@ -408,12 +409,12 @@
 
 /* Initialize a filter iterator: */
 int
-NI_InitFilterIterator(int rank, maybelong *filter_shape,
-                    maybelong filter_size, maybelong *array_shape,
-                    maybelong *origins, NI_FilterIterator *iterator)
+NI_InitFilterIterator(int rank, npy_intp *filter_shape,
+                    npy_intp filter_size, npy_intp *array_shape,
+                    npy_intp *origins, NI_FilterIterator *iterator)
 {
     int ii;
-    maybelong fshape[MAXDIM], forigins[MAXDIM];
+    npy_intp fshape[MAXDIM], forigins[MAXDIM];
 
     for(ii = 0; ii < rank; ii++) {
         fshape[ii] = *filter_shape++;
@@ -424,15 +425,15 @@
     if (rank > 0) {
         iterator->strides[rank - 1] = filter_size;
         for(ii = rank - 2; ii >= 0; ii--) {
-            maybelong step = array_shape[ii + 1] < fshape[ii + 1] ?
+            npy_intp step = array_shape[ii + 1] < fshape[ii + 1] ?
                                                                          array_shape[ii + 1] : fshape[ii + 1];
             iterator->strides[ii] =  iterator->strides[ii + 1] * step;
         }
     }
     for(ii = 0; ii < rank; ii++) {
-        maybelong step = array_shape[ii] < fshape[ii] ?
+        npy_intp step = array_shape[ii] < fshape[ii] ?
                                                                                          array_shape[ii] : fshape[ii];
-        maybelong orgn = fshape[ii] / 2 + forigins[ii];
+        npy_intp orgn = fshape[ii] / 2 + forigins[ii];
         /* stride for stepping back to previous offsets: */
         iterator->backstrides[ii] = (step - 1) * iterator->strides[ii];
         /* initialize boundary extension sizes: */
@@ -445,22 +446,22 @@
 /* Calculate the offsets to the filter points, for all border regions and
      the interior of the array: */
 int NI_InitFilterOffsets(PyArrayObject *array, Bool *footprint,
-         maybelong *filter_shape, maybelong* origins,
-         NI_ExtendMode mode, maybelong **offsets, maybelong *border_flag_value,
-         maybelong **coordinate_offsets)
+         npy_intp *filter_shape, npy_intp* origins,
+         NI_ExtendMode mode, npy_intp **offsets, npy_intp *border_flag_value,
+         npy_intp **coordinate_offsets)
 {
     int rank, ii;
-    maybelong kk, ll, filter_size = 1, offsets_size = 1, max_size = 0;
-    maybelong max_stride = 0, *ashape = NULL, *astrides = NULL;
-    maybelong footprint_size = 0, coordinates[MAXDIM], position[MAXDIM];
-    maybelong fshape[MAXDIM], forigins[MAXDIM], *po, *pc = NULL;
+    npy_intp kk, ll, filter_size = 1, offsets_size = 1, max_size = 0;
+    npy_intp max_stride = 0, *ashape = NULL, *astrides = NULL;
+    npy_intp footprint_size = 0, coordinates[MAXDIM], position[MAXDIM];
+    npy_intp fshape[MAXDIM], forigins[MAXDIM], *po, *pc = NULL;
 
     rank = array->nd;
     ashape = array->dimensions;
     astrides = array->strides;
     for(ii = 0; ii < rank; ii++) {
         fshape[ii] = *filter_shape++;
-        forigins[ii] = origins ? *origins++ : 0.0;
+        forigins[ii] = origins ? *origins++ : 0;
     }
     /* the size of the footprint array: */
     for(ii = 0; ii < rank; ii++)
@@ -477,22 +478,22 @@
     for(ii = 0; ii < rank; ii++)
         offsets_size *= (ashape[ii] < fshape[ii] ? ashape[ii] : fshape[ii]);
     /* allocate offsets data: */
-    *offsets = (maybelong*)malloc(offsets_size * footprint_size *
-                                                                                                                sizeof(maybelong));
+    *offsets = (npy_intp*)malloc(offsets_size * footprint_size *
+                                                        sizeof(npy_intp));
     if (!*offsets) {
         PyErr_NoMemory();
         goto exit;
     }
     if (coordinate_offsets) {
-        *coordinate_offsets = (maybelong*)malloc(offsets_size * rank *
-                                                                             footprint_size * sizeof(maybelong));
+        *coordinate_offsets = (npy_intp*)malloc(offsets_size * rank *
+                                        footprint_size * sizeof(npy_intp));
         if (!*coordinate_offsets) {
             PyErr_NoMemory();
             goto exit;
         }
     }
     for(ii = 0; ii < rank; ii++) {
-        maybelong stride;
+        npy_intp stride;
         /* find maximum axis size: */
         if (ashape[ii] > max_size)
             max_size = ashape[ii];
@@ -518,14 +519,14 @@
     for(ll = 0; ll < offsets_size; ll++) {
         /* iterate over the elements in the footprint array: */
         for(kk = 0; kk < filter_size; kk++) {
-            maybelong offset = 0;
+            npy_intp offset = 0;
             /* only calculate an offset if the footprint is 1: */
             if (!footprint || footprint[kk]) {
                 /* find offsets along all axes: */
                 for(ii = 0; ii < rank; ii++) {
-                    maybelong orgn = fshape[ii] / 2 + forigins[ii];
-                    maybelong cc = coordinates[ii] - orgn + position[ii];
-                    maybelong len = ashape[ii];
+                    npy_intp orgn = fshape[ii] / 2 + forigins[ii];
+                    npy_intp cc = coordinates[ii] - orgn + position[ii];
+                    npy_intp len = ashape[ii];
                     /* apply boundary conditions, if necessary: */
                     switch (mode) {
                     case NI_EXTEND_MIRROR:
@@ -612,8 +613,8 @@
                             pc[ii] = 0;
                         break;
                     } else {
-                        /* use an offset that is possibly mapped from outside the
-                             border: */
+                        /* use an offset that is possibly mapped from outside
+                           the border: */
                         cc = cc - position[ii];
                         offset += astrides[ii] * cc;
                         if (coordinate_offsets)
@@ -705,8 +706,8 @@
         PyErr_NoMemory();
         goto exit;
     }
-    block->coordinates = (maybelong*)malloc(list->block_size * list->rank *
-					  sizeof(maybelong));
+    block->coordinates = (npy_intp*)malloc(list->block_size * list->rank *
+                                                           sizeof(npy_intp));
     if (!block->coordinates) {
         PyErr_NoMemory();
         goto exit;

Modified: trunk/scipy/ndimage/src/ni_support.h
===================================================================
--- trunk/scipy/ndimage/src/ni_support.h	2010-09-12 00:57:08 UTC (rev 6746)
+++ trunk/scipy/ndimage/src/ni_support.h	2010-09-12 00:57:31 UTC (rev 6747)
@@ -63,10 +63,10 @@
 /* the iterator structure: */
 typedef struct {
     int rank_m1;
-    maybelong dimensions[MAXDIM];
-    maybelong coordinates[MAXDIM];
-    maybelong strides[MAXDIM];
-    maybelong backstrides[MAXDIM];
+    npy_intp dimensions[MAXDIM];
+    npy_intp coordinates[MAXDIM];
+    npy_intp strides[MAXDIM];
+    npy_intp backstrides[MAXDIM];
 } NI_Iterator;
 
 /* initialize iterations over single array elements: */
@@ -156,8 +156,8 @@
 /* the linebuffer structure: */
 typedef struct {
     double *buffer_data;
-    maybelong buffer_lines, line_length, line_stride;
-    maybelong size1, size2, array_lines, next_line;
+    npy_intp buffer_lines, line_length, line_stride;
+    npy_intp size1, size2, array_lines, next_line;
     NI_Iterator iterator;
     char* array_data;
     NumarrayType array_type;
@@ -170,18 +170,18 @@
     ((_buffer).buffer_data + (_line) * ((_buffer).line_length +            \
                                                                             (_buffer).size1 + (_buffer).size2))
 /* Allocate line buffer data */
-int NI_AllocateLineBuffer(PyArrayObject*, int, maybelong, maybelong,
-                                                    maybelong*, maybelong, double**);
+int NI_AllocateLineBuffer(PyArrayObject*, int, npy_intp, npy_intp,
+                           npy_intp*, npy_intp, double**);
 
 /* Initialize a line buffer */
-int NI_InitLineBuffer(PyArrayObject*, int, maybelong, maybelong, maybelong,
+int NI_InitLineBuffer(PyArrayObject*, int, npy_intp, npy_intp, npy_intp,
                                             double*, NI_ExtendMode, double, NI_LineBuffer*);
 
 /* Extend a line in memory to implement boundary conditions: */
-int NI_ExtendLine(double*, maybelong, maybelong, maybelong, NI_ExtendMode, double);
+int NI_ExtendLine(double*, npy_intp, npy_intp, npy_intp, NI_ExtendMode, double);
 
 /* Copy a line from an array to a buffer: */
-int NI_ArrayToLineBuffer(NI_LineBuffer*, maybelong*, int*);
+int NI_ArrayToLineBuffer(NI_LineBuffer*, npy_intp*, int*);
 
 /* Copy a line from a buffer to an array: */
 int NI_LineBufferToArray(NI_LineBuffer*);
@@ -192,18 +192,19 @@
 
 /* the filter iterator structure: */
 typedef struct {
-    maybelong strides[MAXDIM], backstrides[MAXDIM];
-    maybelong bound1[MAXDIM], bound2[MAXDIM];
+    npy_intp strides[MAXDIM], backstrides[MAXDIM];
+    npy_intp bound1[MAXDIM], bound2[MAXDIM];
 } NI_FilterIterator;
 
 /* Initialize a filter iterator: */
-int NI_InitFilterIterator(int, maybelong*, maybelong, maybelong*,
-                                                                                    maybelong*, NI_FilterIterator*);
+int NI_InitFilterIterator(int, npy_intp*, npy_intp, npy_intp*,
+                          npy_intp*, NI_FilterIterator*);
 
 /* Calculate the offsets to the filter points, for all border regions and
      the interior of the array: */
-int NI_InitFilterOffsets(PyArrayObject*, Bool*, maybelong*,
-                    maybelong*, NI_ExtendMode, maybelong**, maybelong*, maybelong**);
+int NI_InitFilterOffsets(PyArrayObject*, Bool*, npy_intp*,
+                         npy_intp*, NI_ExtendMode, npy_intp**, 
+                         npy_intp*, npy_intp**);
 
 /* Move to the next point in an array, possible changing the filter
      offsets, to adapt to boundary conditions: */
@@ -211,7 +212,7 @@
 {                                                                 \
     int _ii;                                                        \
     for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) {               \
-        maybelong _pp = (iterator1).coordinates[_ii];                 \
+        npy_intp _pp = (iterator1).coordinates[_ii];              \
         if (_pp < (iterator1).dimensions[_ii]) {                      \
             if (_pp < (iteratorf).bound1[_ii] ||                        \
                                                                     _pp >= (iteratorf).bound2[_ii]) \
@@ -235,7 +236,7 @@
 {                                                           \
     int _ii;                                                  \
     for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) {         \
-        maybelong _pp = (iterator1).coordinates[_ii];           \
+        npy_intp _pp = (iterator1).coordinates[_ii];        \
         if (_pp < (iterator1).dimensions[_ii]) {                \
             if (_pp < (iteratorf).bound1[_ii] ||                  \
                                                         _pp >= (iteratorf).bound2[_ii]) \
@@ -261,7 +262,7 @@
 {                                                                    \
     int _ii;                                                           \
     for(_ii = (iterator1).rank_m1; _ii >= 0; _ii--) {                  \
-        maybelong _pp = (iterator1).coordinates[_ii];                    \
+        npy_intp _pp = (iterator1).coordinates[_ii];                 \
         if (_pp < (iterator1).dimensions[_ii]) {                         \
             if (_pp < (iteratorf).bound1[_ii] ||                           \
                                                                          _pp >= (iteratorf).bound2[_ii]) \
@@ -286,12 +287,12 @@
 #define NI_FILTER_GOTO(iteratorf, iterator, fbase, pointerf) \
 {                                                            \
     int _ii;                                                   \
-    maybelong _jj;                                             \
+    npy_intp _jj;                                             \
     pointerf = fbase;                                          \
     for(_ii = iterator.rank_m1; _ii >= 0; _ii--) {             \
-        maybelong _pp = iterator.coordinates[_ii];               \
-        maybelong b1 = (iteratorf).bound1[_ii];                  \
-        maybelong b2 = (iteratorf).bound2[_ii];                  \
+        npy_intp _pp = iterator.coordinates[_ii];             \
+        npy_intp b1 = (iteratorf).bound1[_ii];                \
+        npy_intp b2 = (iteratorf).bound2[_ii];                \
         if (_pp < b1) {                                          \
                 _jj = _pp;                                           \
         } else if (_pp > b2 && b2 >= b1) {                       \
@@ -304,7 +305,7 @@
 }
 
 typedef struct {
-        maybelong *coordinates;
+    npy_intp *coordinates;
         int size;
         void *next;
 } NI_CoordinateBlock;



More information about the Scipy-svn mailing list