[Scipy-svn] r2886 - trunk/Lib/ndimage/src

scipy-svn@scip... scipy-svn@scip...
Thu Mar 29 04:21:13 CDT 2007


Author: stefan
Date: 2007-03-29 04:20:23 -0500 (Thu, 29 Mar 2007)
New Revision: 2886

Modified:
   trunk/Lib/ndimage/src/nd_image.c
   trunk/Lib/ndimage/src/nd_image.h
   trunk/Lib/ndimage/src/ni_filters.c
   trunk/Lib/ndimage/src/ni_fourier.c
   trunk/Lib/ndimage/src/ni_interpolation.c
   trunk/Lib/ndimage/src/ni_interpolation.h
   trunk/Lib/ndimage/src/ni_measure.c
   trunk/Lib/ndimage/src/ni_morphology.c
   trunk/Lib/ndimage/src/ni_support.c
   trunk/Lib/ndimage/src/ni_support.h
Log:
Pull out numarray dependencies into nd_image header file.  Some tests
in morphology still fail.


Modified: trunk/Lib/ndimage/src/nd_image.c
===================================================================
--- trunk/Lib/ndimage/src/nd_image.c	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/nd_image.c	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #define ND_IMPORT_ARRAY
@@ -46,52 +46,52 @@
 } NI_PythonCallbackData;
 
 /* Convert an input array of any type, not necessarily contiguous */
-static int 
+static int
 NI_ObjectToInputArray(PyObject *object, PyArrayObject **array)
 {
-  *array = NA_InputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED);
+  *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED);
   return *array ? 1 : 0;
 }
 
 /* Convert an input array of any type, not necessarily contiguous */
-static int 
+static int
 NI_ObjectToOptionalInputArray(PyObject *object, PyArrayObject **array)
 {
   if (object == Py_None) {
     *array = NULL;
     return 1;
   } else {
-    *array = NA_InputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED);
+    *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED);
     return *array ? 1 : 0;
   }
 }
 
 /* Convert an output array of any type, not necessarily contiguous */
-static int 
+static int
 NI_ObjectToOutputArray(PyObject *object, PyArrayObject **array)
 {
-  *array = NA_OutputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED);
+  *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED);
   return *array ? 1 : 0;
 }
 
 /* Convert an output array of any type, not necessarily contiguous */
-static int 
+static int
 NI_ObjectToOptionalOutputArray(PyObject *object, PyArrayObject **array)
 {
   if (object == Py_None) {
     *array = NULL;
     return 1;
   } else {
-    *array = NA_OutputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED);
+    *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED);
     return *array ? 1 : 0;
   }
 }
 
 /* Convert an input/output array of any type, not necessarily contiguous */
-static int 
+static int
 NI_ObjectToIoArray(PyObject *object, PyArrayObject **array)
 {
-  *array = NA_IoArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED);
+  *array = NA_IoArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED);
   return *array ? 1 : 0;
 }
 
@@ -100,23 +100,23 @@
 NI_ObjectToLongSequenceAndLength(PyObject *object, maybelong **sequence)
 {
   long *pa, ii;
-  PyArrayObject *array = NA_InputArray(object, PyArray_LONG, C_ARRAY);
+  PyArrayObject *array = NA_InputArray(object, PyArray_LONG, NPY_CARRAY);
   maybelong length = NA_elements(array);
-  
+
   *sequence = (maybelong*)malloc(length * sizeof(maybelong));
   if (!*sequence) {
     PyErr_NoMemory();
     Py_XDECREF(array);
     return -1;
   }
-  pa = (long*)NA_OFFSETDATA(array);
+  pa = (long*)PyArray_DATA(array);
   for(ii = 0; ii < length; ii++)
     (*sequence)[ii] = pa[ii];
   Py_XDECREF(array);
   return length;
 }
 
-static int 
+static int
 NI_ObjectToLongSequence(PyObject *object, maybelong **sequence)
 {
   return NI_ObjectToLongSequenceAndLength(object, sequence) >= 0;
@@ -132,9 +132,9 @@
   int axis, mode;
   long origin;
   double cval;
-  
-  if (!PyArg_ParseTuple(args, "O&O&iO&idl", NI_ObjectToInputArray, &input, 
-                  NI_ObjectToInputArray, &weights, &axis, 
+
+  if (!PyArg_ParseTuple(args, "O&O&iO&idl", NI_ObjectToInputArray, &input,
+                  NI_ObjectToInputArray, &weights, &axis,
                   NI_ObjectToOutputArray, &output, &mode, &cval, &origin))
     goto exit;
   if (!NI_Correlate1D(input, weights, axis, output,
@@ -153,12 +153,12 @@
   maybelong *origin = NULL;
   int mode;
   double cval;
-  
-  if (!PyArg_ParseTuple(args, "O&O&O&idO&", NI_ObjectToInputArray, &input, 
-          NI_ObjectToInputArray, &weights, NI_ObjectToOutputArray, &output, 
+
+  if (!PyArg_ParseTuple(args, "O&O&O&idO&", NI_ObjectToInputArray, &input,
+          NI_ObjectToInputArray, &weights, NI_ObjectToOutputArray, &output,
           &mode, &cval, NI_ObjectToLongSequence, &origin))
     goto exit;
-  if (!NI_Correlate(input, weights, output, (NI_ExtendMode)mode, cval, 
+  if (!NI_Correlate(input, weights, output, (NI_ExtendMode)mode, cval,
                     origin))
     goto exit;
 exit:
@@ -176,8 +176,8 @@
   int axis, mode;
   long filter_size, origin;
   double cval;
-  
-  if (!PyArg_ParseTuple(args, "O&liO&idl", NI_ObjectToInputArray, &input, 
+
+  if (!PyArg_ParseTuple(args, "O&liO&idl", NI_ObjectToInputArray, &input,
                     &filter_size, &axis, NI_ObjectToOutputArray, &output,
                     &mode, &cval, &origin))
     goto exit;
@@ -196,8 +196,8 @@
   int axis, mode, minimum;
   long filter_size, origin;
   double cval;
-  
-  if (!PyArg_ParseTuple(args, "O&liO&idli", NI_ObjectToInputArray, &input, 
+
+  if (!PyArg_ParseTuple(args, "O&liO&idli", NI_ObjectToInputArray, &input,
                     &filter_size, &axis, NI_ObjectToOutputArray, &output,
                     &mode, &cval, &origin, &minimum))
     goto exit;
@@ -217,7 +217,7 @@
   maybelong *origin = NULL;
   int mode, minimum;
   double cval;
-  
+
   if (!PyArg_ParseTuple(args, "O&O&O&O&idO&i", NI_ObjectToInputArray,
                     &input, NI_ObjectToInputArray, &footprint,
                     NI_ObjectToOptionalInputArray, &structure,
@@ -243,7 +243,7 @@
   maybelong *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,
@@ -264,12 +264,12 @@
 static int Py_Filter1DFunc(double *iline, maybelong ilen,
                            double *oline, maybelong olen, void *data)
 {
-  PyArrayObject *py_ibuffer = NULL, *py_obuffer = NULL; 
+  PyArrayObject *py_ibuffer = NULL, *py_obuffer = NULL;
   PyObject *rv = NULL, *args = NULL, *tmp = NULL;
   maybelong ii;
   double *po = NULL;
   NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data;
-  
+
   py_ibuffer = NA_NewArray(iline, PyArray_DOUBLE, 1, (int)ilen);
   py_obuffer = NA_NewArray(NULL, PyArray_DOUBLE, 1, (int)olen);
   if (!py_ibuffer || !py_obuffer)
@@ -283,7 +283,7 @@
   rv = PyObject_Call(cbdata->function, args, cbdata->extra_keywords);
   if (!rv)
     goto exit;
-  po = (double*)NA_OFFSETDATA(py_obuffer);
+  po = (double*)PyArray_DATA(py_obuffer);
   for(ii = 0; ii < olen; ii++)
     oline[ii] = po[ii];
 exit:
@@ -304,9 +304,9 @@
   int axis, mode;
   long origin, filter_size;
   double cval;
-  
-  if (!PyArg_ParseTuple(args, "O&OliO&idlOO", NI_ObjectToInputArray, 
-        &input, &fnc, &filter_size, &axis, NI_ObjectToOutputArray, 
+
+  if (!PyArg_ParseTuple(args, "O&OliO&idlOO", NI_ObjectToInputArray,
+        &input, &fnc, &filter_size, &axis, NI_ObjectToOutputArray,
         &output, &mode, &cval, &origin, &extra_arguments, &extra_keywords))
     goto exit;
   if (!PyTuple_Check(extra_arguments)) {
@@ -378,8 +378,8 @@
   int mode;
   maybelong *origin = NULL;
   double cval;
-  
-  if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO", NI_ObjectToInputArray, 
+
+  if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO", NI_ObjectToInputArray,
                         &input, &fnc, NI_ObjectToInputArray, &footprint,
                         NI_ObjectToOutputArray, &output, &mode, &cval,
                         NI_ObjectToLongSequence, &origin,
@@ -425,15 +425,15 @@
   PyArrayObject *input = NULL, *output = NULL, *parameters = NULL;
   int axis, filter_type;
   long n;
-  
-  if (!PyArg_ParseTuple(args, "O&O&liO&i", NI_ObjectToInputArray, &input, 
+
+  if (!PyArg_ParseTuple(args, "O&O&liO&i", NI_ObjectToInputArray, &input,
                     NI_ObjectToInputArray, &parameters, &n, &axis,
                     NI_ObjectToOutputArray, &output, &filter_type))
-    goto exit;   
-                
+    goto exit;
+
   if (!NI_FourierFilter(input, parameters, n, axis, output, filter_type))
     goto exit;
-    
+
 exit:
   Py_XDECREF(input);
   Py_XDECREF(parameters);
@@ -446,15 +446,15 @@
   PyArrayObject *input = NULL, *output = NULL, *shifts = NULL;
   int axis;
   long n;
-  
-  if (!PyArg_ParseTuple(args, "O&O&liO&", NI_ObjectToInputArray, &input, 
+
+  if (!PyArg_ParseTuple(args, "O&O&liO&", NI_ObjectToInputArray, &input,
                     NI_ObjectToInputArray, &shifts, &n, &axis,
                     NI_ObjectToOutputArray, &output))
-    goto exit;   
-                
+    goto exit;
+
   if (!NI_FourierShift(input, shifts, n, axis, output))
     goto exit;
-    
+
 exit:
   Py_XDECREF(input);
   Py_XDECREF(shifts);
@@ -466,11 +466,11 @@
 {
   PyArrayObject *input = NULL, *output = NULL;
   int axis, order;
-  
+
   if (!PyArg_ParseTuple(args, "O&iiO&", NI_ObjectToInputArray, &input,
           &order, &axis, NI_ObjectToOutputArray, &output))
     goto exit;
-    
+
   if (!NI_SplineFilter1D(input, order, axis, output))
     goto exit;
 
@@ -480,7 +480,7 @@
   return PyErr_Occurred() ? NULL : Py_BuildValue("");
 }
 
-static int Py_Map(maybelong *ocoor, double* icoor, int orank, int irank, 
+static int Py_Map(maybelong *ocoor, double* icoor, int orank, int irank,
                   void *data)
 {
   PyObject *coors = NULL, *rets = NULL, *args = NULL, *tmp = NULL;
@@ -527,10 +527,10 @@
   double cval;
   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, 
+                        &coordinates, NI_ObjectToOptionalInputArray,
                         &matrix, NI_ObjectToOptionalInputArray, &shift,
                         NI_ObjectToOutputArray, &output, &order, &mode,
                         &cval, &extra_arguments, &extra_keywords))
@@ -562,8 +562,8 @@
       goto exit;
     }
   }
-  
-  if (!NI_GeometricTransform(input, func, data, matrix, shift, coordinates, 
+
+  if (!NI_GeometricTransform(input, func, data, matrix, shift, coordinates,
                           output, order, (NI_ExtendMode)mode, cval))
     goto exit;
 
@@ -582,8 +582,8 @@
   PyArrayObject *zoom = NULL;
   int mode, order;
   double cval;
-  
-  if (!PyArg_ParseTuple(args, "O&O&O&O&iid", NI_ObjectToInputArray, 
+
+  if (!PyArg_ParseTuple(args, "O&O&O&O&iid", NI_ObjectToInputArray,
           &input, NI_ObjectToOptionalInputArray, &zoom,
           NI_ObjectToOptionalInputArray, &shift, NI_ObjectToOutputArray,
           &output, &order, &mode, &cval))
@@ -606,10 +606,10 @@
   PyArrayObject *input = NULL, *output = NULL, *strct = NULL;
   maybelong max_label;
 
-  if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, 
+  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))
     goto exit;
 
@@ -632,12 +632,12 @@
   if (!PyArg_ParseTuple(args, "O&l", NI_ObjectToInputArray, &input,
                         &max_label))
     goto exit;
-    
+
   if (max_label < 0)
     max_label = 0;
   if (max_label > 0) {
     if (input->nd > 0) {
-      regions = (maybelong*)malloc(2 * max_label * input->nd * 
+      regions = (maybelong*)malloc(2 * max_label * input->nd *
                                                     sizeof(maybelong));
     } else {
       regions = (maybelong*)malloc(max_label * sizeof(maybelong));
@@ -647,7 +647,7 @@
       goto exit;
     }
   }
-   
+
   if (!NI_FindObjects(input, max_label, regions))
     goto exit;
 
@@ -715,11 +715,11 @@
   PyArrayObject *input = NULL, *output = NULL, *markers = NULL;
   PyArrayObject *strct = NULL;
 
-  if (!PyArg_ParseTuple(args, "O&O&O&O&", NI_ObjectToInputArray, &input, 
+  if (!PyArg_ParseTuple(args, "O&O&O&O&", NI_ObjectToInputArray, &input,
           NI_ObjectToInputArray, &markers, NI_ObjectToInputArray,
           &strct, NI_ObjectToOutputArray, &output))
     goto exit;
-    
+
   if (!NI_WatershedIFT(input, markers, strct, output))
     goto exit;
 
@@ -731,7 +731,7 @@
   return PyErr_Occurred() ? NULL : Py_BuildValue("");
 }
 
-static int _NI_GetIndices(PyObject* indices_object, 
+static int _NI_GetIndices(PyObject* indices_object,
                           maybelong** result_indices, maybelong* min_label,
                           maybelong* max_label, maybelong* n_results)
 {
@@ -765,7 +765,7 @@
         if (indices[ii] > *max_label)
           *max_label = indices[ii];
       }
-      *result_indices = (maybelong*)malloc((*max_label - *min_label + 1) * 
+      *result_indices = (maybelong*)malloc((*max_label - *min_label + 1) *
                                            sizeof(maybelong));
       if (!*result_indices) {
         PyErr_NoMemory();
@@ -912,8 +912,8 @@
   maybelong *lresult1 = NULL, *lresult2 = NULL;
   maybelong min_label, max_label, *result_indices = NULL, n_results, ii;
   int type;
-  
-  if (!PyArg_ParseTuple(args, "O&O&Oi", NI_ObjectToInputArray, &input, 
+
+  if (!PyArg_ParseTuple(args, "O&O&Oi", NI_ObjectToInputArray, &input,
           NI_ObjectToOptionalInputArray, &labels, &indices_object, &type))
     goto exit;
 
@@ -951,53 +951,53 @@
   }
   switch(type) {
   case 0:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
                   n_results, dresult1, NULL, NULL, NULL, NULL, NULL, NULL))
       goto exit;
     result = _NI_BuildMeasurementResultDouble(n_results, dresult1);
     break;
   case 1:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
               n_results, dresult1, lresult1, NULL, NULL, NULL, NULL, NULL))
       goto exit;
     for(ii = 0; ii < n_results; ii++)
       dresult1[ii] = lresult1[ii] > 0 ? dresult1[ii] / lresult1[ii] : 0.0;
-  
+
     result = _NI_BuildMeasurementResultDouble(n_results, dresult1);
-    break;    
+    break;
   case 2:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
           n_results, dresult1, lresult1, dresult2, NULL, NULL, NULL, NULL))
       goto exit;
     result = _NI_BuildMeasurementResultDouble(n_results, dresult2);
     break;
   case 3:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
                   n_results, NULL, NULL, NULL, dresult1, NULL, NULL, NULL))
       goto exit;
     result = _NI_BuildMeasurementResultDouble(n_results, dresult1);
     break;
   case 4:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
                   n_results, NULL, NULL, NULL, NULL, dresult1, NULL, NULL))
       goto exit;
     result = _NI_BuildMeasurementResultDouble(n_results, dresult1);
     break;
   case 5:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
               n_results, NULL, NULL, NULL, dresult1, NULL, lresult1, NULL))
       goto exit;
     result = _NI_BuildMeasurementResultInt(n_results, lresult1);
     break;
   case 6:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
               n_results, NULL, NULL, NULL, NULL, dresult1, NULL, lresult1))
       goto exit;
     result = _NI_BuildMeasurementResultInt(n_results, lresult1);
     break;
   case 7:
-    if (!NI_Statistics(input, labels, min_label, max_label, result_indices, 
-                       n_results, NULL, NULL, NULL, dresult1, dresult2, 
+    if (!NI_Statistics(input, labels, min_label, max_label, result_indices,
+                       n_results, NULL, NULL, NULL, dresult1, dresult2,
                        lresult1, lresult2))
       goto exit;
     res1 = _NI_BuildMeasurementResultDouble(n_results, dresult1);
@@ -1036,8 +1036,8 @@
   PyObject *indices_object, *result = NULL;
   double *center_of_mass = NULL;
   maybelong min_label, max_label, *result_indices = NULL, n_results;
-  
-  if (!PyArg_ParseTuple(args, "O&O&O", NI_ObjectToInputArray, &input, 
+
+  if (!PyArg_ParseTuple(args, "O&O&O", NI_ObjectToInputArray, &input,
                   NI_ObjectToOptionalInputArray, &labels, &indices_object))
     goto exit;
 
@@ -1045,13 +1045,13 @@
                       &max_label, &n_results))
     goto exit;
 
-  center_of_mass = (double*)malloc(input->nd * n_results * 
+  center_of_mass = (double*)malloc(input->nd * n_results *
                                    sizeof(double));
   if (!center_of_mass) {
     PyErr_NoMemory();
     goto exit;
   }
-  
+
   if (!NI_CenterOfMass(input, labels, min_label, max_label,
                        result_indices, n_results, center_of_mass))
     goto exit;
@@ -1101,8 +1101,8 @@
       goto exit;
     }
   }
-  
-  if (!NI_Histogram(input, labels, min_label, max_label, result_indices, 
+
+  if (!NI_Histogram(input, labels, min_label, max_label, result_indices,
                     n_results, histograms, min, max, nbins))
     goto exit;
 
@@ -1130,11 +1130,11 @@
   int metric;
 
   if (!PyArg_ParseTuple(args, "O&iO&O&O&", NI_ObjectToInputArray, &input,
-                        &metric, NI_ObjectToOptionalInputArray, &sampling, 
-                        NI_ObjectToOptionalOutputArray, &output, 
+                        &metric, NI_ObjectToOptionalInputArray, &sampling,
+                        NI_ObjectToOptionalOutputArray, &output,
                         NI_ObjectToOptionalOutputArray, &features))
     goto exit;
-  if (!NI_DistanceTransformBruteForce(input, metric, sampling,  
+  if (!NI_DistanceTransformBruteForce(input, metric, sampling,
                                       output, features))
     goto exit;
 exit:
@@ -1156,9 +1156,9 @@
   if (!NI_DistanceTransformOnePass(strct, distances, features))
     goto exit;
 exit:
-  Py_XDECREF(strct); 
-  Py_XDECREF(distances); 
-  Py_XDECREF(features); 
+  Py_XDECREF(strct);
+  Py_XDECREF(distances);
+  Py_XDECREF(features);
   return PyErr_Occurred() ? NULL : Py_BuildValue("");
 }
 
@@ -1167,7 +1167,7 @@
 {
   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;
@@ -1180,7 +1180,7 @@
   return PyErr_Occurred() ? NULL : Py_BuildValue("");
 }
 
-static void _FreeCoordinateList(void* ptr) 
+static void _FreeCoordinateList(void* ptr)
 {
   NI_FreeCoordinateList((NI_CoordinateList*)ptr);
 }
@@ -1198,12 +1198,12 @@
   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_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, 
+                        origins, invert, center_is_true, &changed,
                         return_coordinates ? &coordinate_list : NULL))
     goto exit;
   if (return_coordinates) {
@@ -1235,15 +1235,15 @@
   int invert, niter;
   maybelong *origins = NULL;
 
-  if (!PyArg_ParseTuple(args, "O&O&O&iO&iO", NI_ObjectToIoArray, &array, 
-          NI_ObjectToInputArray, &strct, NI_ObjectToOptionalInputArray, 
+  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 (PyCObject_Check(cobj)) {
     NI_CoordinateList *cobj_data = PyCObject_AsVoidPtr(cobj);
-    if (!NI_BinaryErosion2(array, strct, mask, niter, origins, invert, 
+    if (!NI_BinaryErosion2(array, strct, mask, niter, origins, invert,
                            &cobj_data))
       goto exit;
   } else {
@@ -1297,9 +1297,9 @@
    METH_VARARGS, ""},
   {"histogram",             (PyCFunction)Py_Histogram,
    METH_VARARGS, ""},
-  {"distance_transform_bf", (PyCFunction)Py_DistanceTransformBruteForce, 
+  {"distance_transform_bf", (PyCFunction)Py_DistanceTransformBruteForce,
    METH_VARARGS, ""},
-  {"distance_transform_op", (PyCFunction)Py_DistanceTransformOnePass, 
+  {"distance_transform_op", (PyCFunction)Py_DistanceTransformOnePass,
    METH_VARARGS, ""},
   {"euclidean_feature_transform",
    (PyCFunction)Py_EuclideanFeatureTransform, METH_VARARGS, ""},
@@ -1313,5 +1313,5 @@
 PyMODINIT_FUNC init_nd_image(void)
 {
   Py_InitModule("_nd_image", methods);
-  import_libnumarray();
+  import_array();
 }

Modified: trunk/Lib/ndimage/src/nd_image.h
===================================================================
--- trunk/Lib/ndimage/src/nd_image.h	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/nd_image.h	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef ND_IMAGE_H
@@ -41,7 +41,7 @@
 #define MAXDIM NPY_MAXDIMS
 
 typedef enum
-{ 
+{
      tAny=-1,
      tBool=PyArray_BOOL,
      tInt8=PyArray_INT8,
@@ -66,12 +66,218 @@
 #endif
 } NumarrayType;
 
-/* int NI_GetArrayRank(PyArrayObject*);
-NumarrayType NI_GetArrayType(PyArrayObject*);
-void NI_GetArrayDimensions(PyArrayObject*, int*);
-void NI_GetArrayStrides(PyArrayObject*, int*);
-char* NI_GetArrayData(PyArrayObject*);
-int NI_ShapeEqual(PyArrayObject*, PyArrayObject*);
-int NI_CheckArray(PyArrayObject*, NumarrayType, int, int*); */
+/* satisfies ensures that 'a' meets a set of requirements and matches
+the specified type.
+*/
+static int
+satisfies(PyArrayObject *a, int requirements, NumarrayType t)
+{
+    int type_ok = (a->descr->type_num == t) || (t == tAny);
 
+    if (PyArray_ISCARRAY(a))
+        return type_ok;
+    if (PyArray_ISBYTESWAPPED(a) && (requirements & NPY_NOTSWAPPED))
+        return 0;
+    if (!PyArray_ISALIGNED(a) && (requirements & NPY_ALIGNED))
+        return 0;
+    if (!PyArray_ISCONTIGUOUS(a) && (requirements & NPY_CONTIGUOUS))
+        return 0;
+    if (!PyArray_ISWRITEABLE(a) && (requirements & NPY_WRITEABLE))
+        return 0;
+    if (requirements & NPY_ENSURECOPY)
+        return 0;
+    return type_ok;
+}
+
+static PyArrayObject*
+NA_InputArray(PyObject *a, NumarrayType t, int requires)
+{
+    PyArray_Descr *descr;
+    if (t == tAny) descr = NULL;
+    else descr = PyArray_DescrFromType(t);
+    return (PyArrayObject *)                                            \
+        PyArray_CheckFromAny(a, descr, 0, 0, requires, NULL);
+}
+
+static PyArrayObject *
+NA_OutputArray(PyObject *a, NumarrayType t, int requires)
+{
+    PyArray_Descr *dtype;
+    PyArrayObject *ret;
+
+    if (!PyArray_Check(a) || !PyArray_ISWRITEABLE(a)) {
+        PyErr_Format(PyExc_TypeError,
+                     "NA_OutputArray: only writeable arrays work for output.");
+        return NULL;
+    }
+
+    if (satisfies((PyArrayObject *)a, requires, t)) {
+        Py_INCREF(a);
+        return (PyArrayObject *)a;
+    }
+    if (t == tAny) {
+        dtype = PyArray_DESCR(a);
+        Py_INCREF(dtype);
+    }
+    else {
+        dtype = PyArray_DescrFromType(t);
+    }
+    ret = (PyArrayObject *)PyArray_Empty(PyArray_NDIM(a), PyArray_DIMS(a),
+                                         dtype, 0);
+    ret->flags |= NPY_UPDATEIFCOPY;
+    ret->base = a;
+    PyArray_FLAGS(a) &= ~NPY_WRITEABLE;
+    Py_INCREF(a);
+    return ret;
+}
+
+/* NA_IoArray is a combination of NA_InputArray and NA_OutputArray.
+
+Unlike NA_OutputArray, if a temporary is required it is initialized to a copy
+of the input array.
+
+Unlike NA_InputArray, deallocating any resulting temporary array results in a
+copy from the temporary back to the original.
+*/
+static PyArrayObject *
+NA_IoArray(PyObject *a, NumarrayType t, int requires)
+{
+    PyArrayObject *shadow = NA_InputArray(a, t, requires | NPY_UPDATEIFCOPY );
+
+    if (!shadow) return NULL;
+
+    /* Guard against non-writable, but otherwise satisfying requires.
+       In this case,  shadow == a.
+    */
+    if (!PyArray_ISWRITEABLE(shadow)) {
+        PyErr_Format(PyExc_TypeError,
+                     "NA_IoArray: I/O array must be writable array");
+        PyArray_XDECREF_ERR(shadow);
+        return NULL;
+    }
+
+    return shadow;
+}
+
+static unsigned long
+NA_elements(PyArrayObject  *a)
+{
+    int i;
+    unsigned long n = 1;
+    for(i = 0; i<a->nd; i++)
+        n *= a->dimensions[i];
+    return n;
+}
+
+#define NUM_LITTLE_ENDIAN 0
+#define NUM_BIG_ENDIAN 1
+
+static int
+NA_ByteOrder(void)
+{
+    unsigned long byteorder_test;
+    byteorder_test = 1;
+    if (*((char *) &byteorder_test))
+        return NUM_LITTLE_ENDIAN;
+    else
+        return NUM_BIG_ENDIAN;
+}
+
+/* ignores bytestride */
+static PyArrayObject *
+NA_NewAllFromBuffer(int ndim, maybelong *shape, NumarrayType type,
+                    PyObject *bufferObject, maybelong byteoffset, maybelong bytestride,
+                    int byteorder, int aligned, int writeable)
+{
+    PyArrayObject *self = NULL;
+    PyArray_Descr *dtype;
+
+    if (type == tAny)
+        type = tDefault;
+
+    dtype = PyArray_DescrFromType(type);
+    if (dtype == NULL) return NULL;
+
+    if (byteorder != NA_ByteOrder()) {
+        PyArray_Descr *temp;
+        temp = PyArray_DescrNewByteorder(dtype, PyArray_SWAP);
+        Py_DECREF(dtype);
+        if (temp == NULL) return NULL;
+        dtype = temp;
+    }
+
+    if (bufferObject == Py_None || bufferObject == NULL) {
+        self = (PyArrayObject *)                                        \
+            PyArray_NewFromDescr(&PyArray_Type, dtype,
+                                 ndim, shape, NULL, NULL,
+                                 0, NULL);
+    }
+    else {
+        npy_intp size = 1;
+        int i;
+        PyArrayObject *newself;
+        PyArray_Dims newdims;
+        for(i=0; i<ndim; i++) {
+            size *= shape[i];
+        }
+        self = (PyArrayObject *)                                \
+            PyArray_FromBuffer(bufferObject, dtype,
+                               size, byteoffset);
+        if (self == NULL) return self;
+        newdims.len = ndim;
+        newdims.ptr = shape;
+        newself = (PyArrayObject *)                                     \
+            PyArray_Newshape(self, &newdims, PyArray_CORDER);
+        Py_DECREF(self);
+        self = newself;
+    }
+
+    return self;
+}
+
+#define NA_NBYTES(a) (a->descr->elsize * NA_elements(a))
+
+static PyArrayObject *
+NA_NewAll(int ndim, maybelong *shape, NumarrayType type,
+          void *buffer, maybelong byteoffset, maybelong bytestride,
+          int byteorder, int aligned, int writeable)
+{
+    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");
+            result = NULL;
+        } else {
+            if (buffer) {
+                memcpy(result->data, buffer, NA_NBYTES(result));
+            } else {
+                memset(result->data, 0, NA_NBYTES(result));
+            }
+        }
+    }
+    return  result;
+}
+
+/* Create a new numarray which is initially a C_array, or which
+references a C_array: aligned, !byteswapped, contiguous, ...
+Call with buffer==NULL to allocate storage.
+*/
+static PyArrayObject *
+NA_NewArray(void *buffer, NumarrayType type, int ndim, maybelong *shape)
+{
+    return (PyArrayObject *) NA_NewAll(ndim, shape, type, buffer, 0, 0,
+                                       NA_ByteOrder(), 1, 1);
+}
+
+
+#define  NA_InputArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_InputArray)
+#define  NA_OutputArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_OutputArray)
+#define  NA_IoArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_IoArray)
+#define  NA_elements (*(unsigned long (*) (PyArrayObject*) ) (void *) NA_elements)
+#define  NA_NewArray (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, ...) ) (void *) NA_NewArray )
+
 #endif

Modified: trunk/Lib/ndimage/src/ni_filters.c
===================================================================
--- trunk/Lib/ndimage/src/ni_filters.c	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_filters.c	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "ni_support.h"
@@ -50,7 +50,7 @@
   filter_size = weights->dimensions[0];
   size1 = filter_size / 2;
   size2 = filter_size - size1 - 1;
-  fw = NA_OFFSETDATA(weights);
+  fw = (void *)PyArray_DATA(weights);
   if (filter_size & 0x1) {
     symmetric = 1;
     for(ii = 1; ii <= filter_size / 2; ii++) {
@@ -74,13 +74,13 @@
   if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin,
                              &lines, BUFFER_SIZE, &ibuffer))
     goto exit;
-  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, 
+  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE,
                              &obuffer))
     goto exit;
-  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, 
+  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin,
                               lines, ibuffer, mode, cval, &iline_buffer))
     goto exit;
-  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, 
+  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0,
                          &oline_buffer))
     goto exit;
   length = input->nd > 0 ? input->dimensions[axis] : 1;
@@ -162,12 +162,12 @@
   Float64 *pw;
   Float64 *ww = NULL;
   int ll;
-  
+
   /* get the the footprint: */
   fsize = 1;
   for(ll = 0; ll < weights->nd; ll++)
     fsize *= weights->dimensions[ll];
-  pw = (Float64*)NA_OFFSETDATA(weights);
+  pw = (Float64*)PyArray_DATA(weights);
   pf = (Bool*)malloc(fsize * sizeof(Bool));
   if (!pf) {
     PyErr_NoMemory();
@@ -208,8 +208,8 @@
   if (!NI_InitPointIterator(output, &io))
     goto exit;
   /* get data pointers an array size: */
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(ll = 0; ll < input->nd; ll++)
     size *= input->dimensions[ll];
@@ -229,7 +229,7 @@
 #if HAS_UINT64
       CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt64,
                            tmp, border_flag_value);
-#endif 
+#endif
       CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int8,
                            tmp, border_flag_value);
       CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int16,
@@ -253,7 +253,7 @@
       CASE_FILTER_OUT(po, tmp, UInt32);
 #if HAS_UINT64
       CASE_FILTER_OUT(po, tmp, UInt64);
-#endif 
+#endif
       CASE_FILTER_OUT(po, tmp, Int8);
       CASE_FILTER_OUT(po, tmp, Int16);
       CASE_FILTER_OUT(po, tmp, Int32);
@@ -290,17 +290,17 @@
   if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin,
                              &lines, BUFFER_SIZE, &ibuffer))
     goto exit;
-  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, 
+  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE,
                              &obuffer))
     goto exit;
-  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, 
+  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin,
                               lines, ibuffer, mode, cval, &iline_buffer))
     goto exit;
-  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, 
+  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0,
                          &oline_buffer))
     goto exit;
   length = input->nd > 0 ? input->dimensions[axis] : 1;
-  
+
   /* iterate over all the array lines: */
   do {
     /* copy lines from array to buffer: */
@@ -352,17 +352,17 @@
   if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin,
                              &lines, BUFFER_SIZE, &ibuffer))
     goto exit;
-  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, 
+  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE,
                              &obuffer))
     goto exit;
-  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, 
+  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin,
                                lines, ibuffer, mode, cval, &iline_buffer))
     goto exit;
-  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, 
+  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0,
                          &oline_buffer))
     goto exit;
   length = input->nd > 0 ? input->dimensions[axis] : 1;
-  
+
   /* iterate over all the array lines: */
   do {
     /* copy lines from array to buffer: */
@@ -378,7 +378,7 @@
         double val = iline[ll - size1];
         for(jj = -size1 + 1; jj <= size2; jj++) {
           double tmp = iline[ll + jj];
-          if (minimum) { 
+          if (minimum) {
             if (tmp < val)
               val = tmp;
           } else {
@@ -439,12 +439,12 @@
   int ll;
   double *ss = NULL;
   Float64 *ps;
-  
+
   /* get the the footprint: */
   fsize = 1;
   for(ll = 0; ll < footprint->nd; ll++)
     fsize *= footprint->dimensions[ll];
-  pf = (Bool*)NA_OFFSETDATA(footprint);
+  pf = (Bool*)PyArray_DATA(footprint);
   for(jj = 0; jj < fsize; jj++) {
     if (pf[jj]) {
       ++filter_size;
@@ -458,7 +458,7 @@
       goto exit;
     }
     /* copy the weights to contiguous memory: */
-    ps = (Float64*)NA_OFFSETDATA(structure);
+    ps = (Float64*)PyArray_DATA(structure);
     jj = 0;
     for(kk = 0; kk < fsize; kk++)
       if (pf[kk])
@@ -469,7 +469,7 @@
                             mode, &offsets, &border_flag_value, NULL))
     goto exit;
   /* initialize filter iterator: */
-  if (!NI_InitFilterIterator(input->nd, footprint->dimensions, 
+  if (!NI_InitFilterIterator(input->nd, footprint->dimensions,
                              filter_size, input->dimensions, origins, &fi))
     goto exit;
   /* initialize input element iterator: */
@@ -479,8 +479,8 @@
   if (!NI_InitPointIterator(output, &io))
     goto exit;
   /* get data pointers an array size: */
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(ll = 0; ll < input->nd; ll++)
     size *= input->dimensions[ll];
@@ -500,7 +500,7 @@
 #if HAS_UINT64
       CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt64,
                             minimum, tmp, border_flag_value, ss);
-#endif 
+#endif
       CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int8,
                             minimum, tmp, border_flag_value, ss);
       CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int16,
@@ -524,7 +524,7 @@
       CASE_FILTER_OUT(po, tmp, UInt32);
 #if HAS_UINT64
       CASE_FILTER_OUT(po, tmp, UInt64);
-#endif 
+#endif
       CASE_FILTER_OUT(po, tmp, Int8);
       CASE_FILTER_OUT(po, tmp, Int16);
       CASE_FILTER_OUT(po, tmp, Int32);
@@ -544,37 +544,37 @@
 }
 
 static double NI_Select(double *buffer, int min, int max, int rank)
-{                                                                
-  int ii, jj;                                                        
-  double x, t;                                                        
-                                                                
-  if (min == max)                                                
-    return buffer[min];                                                
-                                                                
-  x = buffer[min];                                                
-  ii = min - 1;                                                        
-  jj = max + 1;                                                        
-  for(;;) {                                                        
-    do                                                                
-      jj--;                                                        
-    while(buffer[jj] > x);                                        
-    do                                                                
-      ii++;                                                        
-    while(buffer[ii] < x);                                        
-    if (ii < jj) {                                                
-      t = buffer[ii];                                                
-      buffer[ii] = buffer[jj];                                        
-      buffer[jj] = t;                                                
-    } else {                                                        
-      break;                                                        
-    }                                                                
-  }                                                                
-                                                                
-  ii = jj - min + 1;                                                
-  if (rank < ii)                                                
-    return NI_Select(buffer, min, jj, rank);                        
-  else                                                                
-    return NI_Select(buffer, jj + 1, max, rank - ii);                
+{
+  int ii, jj;
+  double x, t;
+
+  if (min == max)
+    return buffer[min];
+
+  x = buffer[min];
+  ii = min - 1;
+  jj = max + 1;
+  for(;;) {
+    do
+      jj--;
+    while(buffer[jj] > x);
+    do
+      ii++;
+    while(buffer[ii] < x);
+    if (ii < jj) {
+      t = buffer[ii];
+      buffer[ii] = buffer[jj];
+      buffer[jj] = t;
+    } else {
+      break;
+    }
+  }
+
+  ii = jj - min + 1;
+  if (rank < ii)
+    return NI_Select(buffer, min, jj, rank);
+  else
+    return NI_Select(buffer, jj + 1, max, rank - ii);
 }
 
 #define CASE_RANK_POINT(_pi, _offsets, _filter_size, _cval, _type, \
@@ -593,7 +593,7 @@
 }                                                                  \
 break
 
-int NI_RankFilter(PyArrayObject* input, int rank, 
+int NI_RankFilter(PyArrayObject* input, int rank,
                   PyArrayObject* footprint, PyArrayObject* output,
                   NI_ExtendMode mode, double cvalue, maybelong *origins)
 {
@@ -605,12 +605,12 @@
   Bool *pf = NULL;
   double *buffer = NULL;
   int ll;
-  
+
   /* get the the footprint: */
   fsize = 1;
   for(ll = 0; ll < footprint->nd; ll++)
     fsize *= footprint->dimensions[ll];
-  pf = (Bool*)NA_OFFSETDATA(footprint);
+  pf = (Bool*)PyArray_DATA(footprint);
   for(jj = 0; jj < fsize; jj++) {
     if (pf[jj]) {
       ++filter_size;
@@ -625,11 +625,11 @@
   /* iterator over the elements: */
   oo = offsets;
   /* initialize filter offsets: */
-  if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, 
+  if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins,
                             mode, &offsets, &border_flag_value, NULL))
     goto exit;
   /* initialize filter iterator: */
-  if (!NI_InitFilterIterator(input->nd, footprint->dimensions, 
+  if (!NI_InitFilterIterator(input->nd, footprint->dimensions,
                              filter_size, input->dimensions, origins, &fi))
     goto exit;
   /* initialize input element iterator: */
@@ -639,8 +639,8 @@
   if (!NI_InitPointIterator(output, &io))
     goto exit;
   /* get data pointers an array size: */
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(ll = 0; ll < input->nd; ll++)
     size *= input->dimensions[ll];
@@ -660,7 +660,7 @@
 #if HAS_UINT64
       CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt64,
                       rank, buffer, tmp, border_flag_value);
-#endif 
+#endif
       CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int8,
                       rank, buffer, tmp, border_flag_value);
       CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int16,
@@ -684,7 +684,7 @@
       CASE_FILTER_OUT(po, tmp, UInt32);
 #if HAS_UINT64
       CASE_FILTER_OUT(po, tmp, UInt64);
-#endif 
+#endif
       CASE_FILTER_OUT(po, tmp, Int8);
       CASE_FILTER_OUT(po, tmp, Int16);
       CASE_FILTER_OUT(po, tmp, Int32);
@@ -705,7 +705,7 @@
 
 int NI_GenericFilter1D(PyArrayObject *input,
         int (*function)(double*, maybelong, double*, maybelong, void*),
-        void* data, long filter_size, int axis, PyArrayObject *output, 
+        void* data, long filter_size, int axis, PyArrayObject *output,
         NI_ExtendMode mode, double cval, long origin)
 {
   int more;
@@ -720,13 +720,13 @@
   if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin,
                              &lines, BUFFER_SIZE, &ibuffer))
     goto exit;
-  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, 
+  if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE,
                              &obuffer))
     goto exit;
-  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, 
+  if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin,
                               lines, ibuffer, mode, cval, &iline_buffer))
     goto exit;
-  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, 
+  if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0,
                          &oline_buffer))
     goto exit;
   length = input->nd > 0 ? input->dimensions[axis] : 1;
@@ -741,11 +741,11 @@
       double *iline = NI_GET_LINE(iline_buffer, ii);
       double *oline = NI_GET_LINE(oline_buffer, ii);
       if (!function(iline, length + size1 + size2, oline, length, data)) {
-        if (!PyErr_Occurred())                                                 
-          PyErr_SetString(PyExc_RuntimeError,                                 
-                          "unknown error in line processing function");                 
-        goto exit;                                                           
-      }   
+        if (!PyErr_Occurred())
+          PyErr_SetString(PyExc_RuntimeError,
+                          "unknown error in line processing function");
+        goto exit;
+      }
     }
     /* copy lines from buffer to array: */
     if (!NI_LineBufferToArray(&oline_buffer))
@@ -792,12 +792,12 @@
   char *pi, *po;
   double *buffer = NULL;
   int ll;
-  
+
   /* get the the footprint: */
   fsize = 1;
   for(ll = 0; ll < footprint->nd; ll++)
     fsize *= footprint->dimensions[ll];
-  pf = (Bool*)NA_OFFSETDATA(footprint);
+  pf = (Bool*)PyArray_DATA(footprint);
   for(jj = 0; jj < fsize; jj++) {
     if (pf[jj])
       ++filter_size;
@@ -807,7 +807,7 @@
                             mode, &offsets, &border_flag_value, NULL))
     goto exit;
   /* initialize filter iterator: */
-  if (!NI_InitFilterIterator(input->nd, footprint->dimensions, 
+  if (!NI_InitFilterIterator(input->nd, footprint->dimensions,
                              filter_size, input->dimensions, origins, &fi))
     goto exit;
   /* initialize input element iterator: */
@@ -817,8 +817,8 @@
   if (!NI_InitPointIterator(output, &io))
     goto exit;
   /* get data pointers an array size: */
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(ll = 0; ll < input->nd; ll++)
     size *= input->dimensions[ll];
@@ -844,7 +844,7 @@
 #if HAS_UINT64
       CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt64,
                         tmp, border_flag_value, function, data, buffer);
-#endif 
+#endif
       CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int8,
                         tmp, border_flag_value, function, data, buffer);
       CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int16,
@@ -868,7 +868,7 @@
       CASE_FILTER_OUT(po, tmp, UInt32);
 #if HAS_UINT64
       CASE_FILTER_OUT(po, tmp, UInt64);
-#endif 
+#endif
       CASE_FILTER_OUT(po, tmp, Int8);
       CASE_FILTER_OUT(po, tmp, Int16);
       CASE_FILTER_OUT(po, tmp, Int32);
@@ -886,5 +886,3 @@
   if (buffer) free(buffer);
   return PyErr_Occurred() ? 0 : 1;
 }
-
-

Modified: trunk/Lib/ndimage/src/ni_fourier.c
===================================================================
--- trunk/Lib/ndimage/src/ni_fourier.c	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_fourier.c	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "ni_support.h"
@@ -135,14 +135,14 @@
   w = x;
   if (x < 0)
     w = -x;
-  
+
   if (w <= 5.0) {
-    z = x * x;        
+    z = x * x;
     w = polevl(z, RP, 3) / p1evl(z, RQ, 8);
     w = w * x * (z - Z1) * (z - Z2);
     return w ;
   }
-  
+
   w = 5.0 / x;
   z = w * w;
   p = polevl(z, PP, 6) / polevl(z, PQ, 6);
@@ -159,20 +159,20 @@
 
 #define CASE_FOURIER_OUT_RC(_po, _tmp, _type) \
 case t ## _type:                              \
-  (*(_type*)_po).r = tmp;                     \
-  (*(_type*)_po).i = 0.0;                     \
+  (*(_type*)_po).real = tmp;                  \
+  (*(_type*)_po).imag = 0.0;                  \
   break
 
 #define CASE_FOURIER_OUT_CC(_po, _tmp_r, _tmp_i, _type) \
 case t ## _type:                                        \
-  (*(_type*)_po).r = _tmp_r;                            \
-  (*(_type*)_po).i = _tmp_i;                            \
+  (*(_type*)_po).real = _tmp_r;                         \
+  (*(_type*)_po).imag = _tmp_i;                         \
   break
 
 #define CASE_FOURIER_FILTER_RC(_pi, _tmp, _tmp_r, _tmp_i, _type) \
 case t ## _type:                                                 \
-  _tmp_r = (*(_type*)_pi).r * _tmp;                              \
-  _tmp_i = (*(_type*)_pi).i * _tmp;                              \
+  _tmp_r = (*(_type*)_pi).real * _tmp;                           \
+  _tmp_i = (*(_type*)_pi).imag * _tmp;                           \
   break;
 
 #define CASE_FOURIER_FILTER_RR(_pi, _tmp, _type) \
@@ -180,16 +180,16 @@
   _tmp *= *(_type*)_pi;                          \
   break;
 
-int NI_FourierFilter(PyArrayObject *input, PyArrayObject* parameter_array, 
+int NI_FourierFilter(PyArrayObject *input, PyArrayObject* parameter_array,
             maybelong n, int axis, PyArrayObject* output, int filter_type)
 {
   NI_Iterator ii, io;
   char *pi, *po;
   double *parameters = NULL, **params = NULL;
   maybelong kk, hh, size;
-  Float64 *iparameters = NA_OFFSETDATA(parameter_array);
+  Float64 *iparameters = (void *)PyArray_DATA(parameter_array);
   int ll;
-  
+
   /* precalculate the parameters: */
   parameters = (double*)malloc(input->nd * sizeof(double));
   if (!parameters) {
@@ -200,7 +200,7 @@
     /* along the direction of the real transform we must use the given
        length of that dimensons, unless a complex transform is assumed
        (n < 0): */
-    int shape = kk == axis ? 
+    int shape = kk == axis ?
             (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk];
     switch (filter_type) {
       case _NI_GAUSSIAN:
@@ -219,7 +219,7 @@
     PyErr_NoMemory();
     goto exit;
   }
-  for(kk = 0; kk < input->nd; kk++) 
+  for(kk = 0; kk < input->nd; kk++)
     params[kk] = NULL;
   for(kk = 0; kk < input->nd; kk++) {
     if (input->dimensions[kk] > 1) {
@@ -262,7 +262,7 @@
           if (hh == axis && n >= 0) {
             double tmp = M_PI * parameters[hh] / n;
             for(kk = 1; kk < input->dimensions[hh]; kk++)
-              params[hh][kk] = tmp > 0.0 ? 
+              params[hh][kk] = tmp > 0.0 ?
                                       sin(tmp * kk) / (tmp * kk) : 0.0;
           } else {
             double tmp = M_PI * parameters[hh] / input->dimensions[hh];
@@ -275,7 +275,7 @@
                                       sin(tmp * kk) / (tmp * kk) : 0.0;
           }
         }
-      }    
+      }
       break;
     case _NI_ELLIPSOID:
       /* calculate the tables of parameters: */
@@ -312,8 +312,8 @@
   /* initialize output element iterator: */
   if (!NI_InitPointIterator(output, &io))
     goto exit;
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(ll = 0; ll < input->nd; ll++)
     size *= input->dimensions[ll];
@@ -363,14 +363,14 @@
         input->descr->type_num == tComplex64) {
       double tmp_r = 0.0, tmp_i = 0.0;
       switch (input->descr->type_num) {
-        CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex32);
+          /*CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex32);*/
         CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex64);
       default:
         PyErr_SetString(PyExc_RuntimeError, "data type not supported");
         goto exit;
       }
       switch (output->descr->type_num) {
-        CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex32);
+          /*CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex32);*/
         CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex64);
       default:
         PyErr_SetString(PyExc_RuntimeError, "data type not supported");
@@ -398,7 +398,7 @@
       switch (output->descr->type_num) {
         CASE_FOURIER_OUT_RR(po, tmp, Float32);
         CASE_FOURIER_OUT_RR(po, tmp, Float64);
-        CASE_FOURIER_OUT_RC(po, tmp, Complex32);
+        /*CASE_FOURIER_OUT_RC(po, tmp, Complex32);*/
         CASE_FOURIER_OUT_RC(po, tmp, Complex64);
       default:
         PyErr_SetString(PyExc_RuntimeError, "data type not supported");
@@ -407,7 +407,7 @@
     }
     NI_ITERATOR_NEXT2(ii, io, pi, po);
   }
-  
+
  exit:
   if (parameters) free(parameters);
   if (params) {
@@ -425,22 +425,22 @@
   _i = _tmp * _sint;                                                 \
   break;
 
-#define CASE_FOURIER_SHIFT_C(_pi, _r, _i, _cost, _sint, _type) \
-case t ## _type:                                               \
-  _r = (*(_type*)_pi).r * _cost - (*(_type*)_pi).i * _sint;    \
-  _i = (*(_type*)_pi).r * _sint + (*(_type*)_pi).i * _cost;    \
+#define CASE_FOURIER_SHIFT_C(_pi, _r, _i, _cost, _sint, _type)     \
+case t ## _type:                                                   \
+  _r = (*(_type*)_pi).real * _cost - (*(_type*)_pi).imag * _sint;  \
+  _i = (*(_type*)_pi).real * _sint + (*(_type*)_pi).imag * _cost;  \
   break;
 
-int NI_FourierShift(PyArrayObject *input, PyArrayObject* shift_array, 
+int NI_FourierShift(PyArrayObject *input, PyArrayObject* shift_array,
       maybelong n, int axis, PyArrayObject* output)
 {
   NI_Iterator ii, io;
   char *pi, *po;
   double *shifts = NULL, **params = NULL;
   maybelong kk, hh, size;
-  Float64 *ishifts = NA_OFFSETDATA(shift_array);
+  Float64 *ishifts = (void *)PyArray_DATA(shift_array);
   int ll;
-  
+
   /* precalculate the shifts: */
   shifts = (double*)malloc(input->nd * sizeof(double));
   if (!shifts) {
@@ -451,9 +451,9 @@
     /* along the direction of the real transform we must use the given
        length of that dimensons, unless a complex transform is assumed
        (n < 0): */
-    int shape = kk == axis ? 
+    int shape = kk == axis ?
             (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk];
-    shifts[kk] = -2.0 * M_PI * *ishifts++ / (double)shape;        
+    shifts[kk] = -2.0 * M_PI * *ishifts++ / (double)shape;
   }
   /* allocate memory for tables: */
   params = (double**) malloc(input->nd * sizeof(double*));
@@ -461,7 +461,7 @@
     PyErr_NoMemory();
     goto exit;
   }
-  for(kk = 0; kk < input->nd; kk++) 
+  for(kk = 0; kk < input->nd; kk++)
     params[kk] = NULL;
   for(kk = 0; kk < input->nd; kk++) {
     if (input->dimensions[kk] > 1) {
@@ -494,8 +494,8 @@
   /* initialize output element iterator: */
   if (!NI_InitPointIterator(output, &io))
     goto exit;
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(ll = 0; ll < input->nd; ll++)
     size *= input->dimensions[ll];
@@ -521,14 +521,14 @@
       CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int64)
       CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float32)
       CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float64)
-      CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex32)
+          /*CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex32)*/
       CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex64)
     default:
       PyErr_SetString(PyExc_RuntimeError, "data type not supported");
       goto exit;
     }
     switch (output->descr->type_num) {
-      CASE_FOURIER_OUT_CC(po, r, i, Complex32);
+        /*CASE_FOURIER_OUT_CC(po, r, i, Complex32);*/
       CASE_FOURIER_OUT_CC(po, r, i, Complex64);
     default:
       PyErr_SetString(PyExc_RuntimeError, "data type not supported");
@@ -536,7 +536,7 @@
     }
     NI_ITERATOR_NEXT2(ii, io, pi, po);
   }
-  
+
  exit:
   if (shifts) free(shifts);
   if (params) {
@@ -546,4 +546,3 @@
   }
   return PyErr_Occurred() ? 0 : 1;
 }
-

Modified: trunk/Lib/ndimage/src/ni_interpolation.c
===================================================================
--- trunk/Lib/ndimage/src/ni_interpolation.c	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_interpolation.c	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "ni_support.h"
@@ -36,7 +36,7 @@
 
 /* calculate the B-spline interpolation coefficients for given x: */
 static void
-spline_coefficients(double x, int order, double *result) 
+spline_coefficients(double x, int order, double *result)
 {
   int hh;
   double y, start;
@@ -66,21 +66,21 @@
       break;
     case 3:
       if (y < 1.0) {
-        result[hh] = 
+        result[hh] =
           (y * y * (y - 2.0) * 3.0 + 4.0) / 6.0;
       } else if (y < 2.0) {
         y = 2.0 - y;
         result[hh] = y * y * y / 6.0;
       } else {
         result[hh] = 0.0;
-      }        
+      }
       break;
     case 4:
       if (y < 0.5) {
         y *= y;
         result[hh] = y * (y * 0.25 - 0.625) + 115.0 / 192.0;
       } else if (y < 1.5) {
-        result[hh] = y * (y * (y * (5.0 / 6.0 - y / 6.0) - 1.25) + 
+        result[hh] = y * (y * (y * (5.0 / 6.0 - y / 6.0) - 1.25) +
                           5.0 / 24.0) + 55.0 / 96.0;
       } else if (y < 2.5) {
         y -= 2.5;
@@ -93,10 +93,10 @@
     case 5:
       if (y < 1.0) {
         double f = y * y;
-        result[hh] = 
+        result[hh] =
           f * (f * (0.25 - y / 12.0) - 0.5) + 0.55;
       } else if (y < 2.0) {
-        result[hh] = y * (y * (y * (y * (y / 24.0 - 0.375) 
+        result[hh] = y * (y * (y * (y * (y / 24.0 - 0.375)
                                     + 1.25) -  1.75) + 0.625) + 0.425;
       } else if (y < 3.0) {
         double f = 3.0 - y;
@@ -112,7 +112,7 @@
 
 /* map a coordinate outside the borders, according to the requested
    boundary condition: */
-static double 
+static double
 map_coordinate(double in, maybelong len, int mode)
 {
   if (in < 0) {
@@ -136,7 +136,7 @@
         in = in < -len ? in + sz2 : -in - 1;
       }
       break;
-    case NI_EXTEND_WRAP: 
+    case NI_EXTEND_WRAP:
       if (len <= 1) {
         in = 0;
       } else {
@@ -175,7 +175,7 @@
           in = sz2 - in - 1;
       }
       break;
-    case NI_EXTEND_WRAP: 
+    case NI_EXTEND_WRAP:
       if (len <= 1) {
         in = 0;
       } else {
@@ -199,7 +199,7 @@
 #define TOLERANCE 1e-15
 
 /* one-dimensional spline filter: */
-int NI_SplineFilter1D(PyArrayObject *input, int order, int axis, 
+int NI_SplineFilter1D(PyArrayObject *input, int order, int axis,
                       PyArrayObject *output)
 {
   int hh, npoles = 0, more;
@@ -251,7 +251,7 @@
   if (!NI_InitLineBuffer(output, axis, 0, 0, lines, buffer,
                          NI_EXTEND_DEFAULT, 0.0, &oline_buffer))
     goto exit;
-  
+
   /* iterate over all the array lines: */
   do {
     /* copy lines from array to buffer: */
@@ -265,36 +265,36 @@
       if (len > 1) {
         for(ll = 0; ll < len; ll++)
           ln[ll] *= weight;
-        for(hh = 0; hh < npoles; hh++) {                                
-          double p = pole[hh];                                        
+        for(hh = 0; hh < npoles; hh++) {
+          double p = pole[hh];
           int max = (int)ceil(log(TOLERANCE) / log(fabs(p)));
-          if (max < len) {                                                
-            double zn = p;                                                
-            double sum = ln[0];                                        
-            for(ll = 1; ll < max; ll++) {                                
-              sum += zn * ln[ll];                                        
-              zn *= p;                                                
-            }                                                        
-            ln[0] = sum;                                                
-          } else {                                                        
-            double zn = p;                                                
-            double iz = 1.0 / p;                                        
-            double z2n = pow(p, (double)(len - 1));                        
-            double sum = ln[0] + z2n * ln[len - 1];                        
-            z2n *= z2n * iz;                                        
-            for(ll = 1; ll <= len - 2; ll++) {                        
-              sum += (zn + z2n) * ln[ll];                                
-              zn *= p;                                                
-              z2n *= iz;                                                
-            }                                                        
+          if (max < len) {
+            double zn = p;
+            double sum = ln[0];
+            for(ll = 1; ll < max; ll++) {
+              sum += zn * ln[ll];
+              zn *= p;
+            }
+            ln[0] = sum;
+          } else {
+            double zn = p;
+            double iz = 1.0 / p;
+            double z2n = pow(p, (double)(len - 1));
+            double sum = ln[0] + z2n * ln[len - 1];
+            z2n *= z2n * iz;
+            for(ll = 1; ll <= len - 2; ll++) {
+              sum += (zn + z2n) * ln[ll];
+              zn *= p;
+              z2n *= iz;
+            }
             ln[0] = sum / (1.0 - zn * zn);
-          }                                                                
-          for(ll = 1; ll < len; ll++)                                
-            ln[ll] += p * ln[ll - 1];                                
+          }
+          for(ll = 1; ll < len; ll++)
+            ln[ll] += p * ln[ll - 1];
           ln[len-1] = (p / (p * p - 1.0)) * (ln[len-1] + p * ln[len-2]);
-          for(ll = len - 2; ll >= 0; ll--)                                
-            ln[ll] = p * (ln[ll + 1] - ln[ll]);                        
-        }                                                                
+          for(ll = len - 2; ll >= 0; ll--)
+            ln[ll] = p * (ln[ll + 1] - ln[ll]);
+        }
       }
     }
     /* copy lines from buffer to array: */
@@ -306,7 +306,7 @@
   if (buffer) free(buffer);
   return PyErr_Occurred() ? 0 : 1;
 }
- 
+
 #define CASE_MAP_COORDINATES(_p, _coor, _rank, _stride, _type) \
 case t ## _type:                                                    \
 {                                                              \
@@ -321,7 +321,7 @@
 #define CASE_INTERP_COEFF(_coeff, _pi, _idx, _type) \
 case t ## _type:                                    \
   _coeff = *(_type*)(_pi + _idx);                   \
-  break;                                          
+  break;
 
 #define CASE_INTERP_OUT(_po, _t, _type) \
 case t ## _type:                        \
@@ -344,8 +344,8 @@
   *(_type*)_po = (_type)_t;                 \
   break;
 
-int 
-NI_GeometricTransform(PyArrayObject *input, int (*map)(maybelong*, double*, 
+int
+NI_GeometricTransform(PyArrayObject *input, int (*map)(maybelong*, double*,
         int, int, void*), void* map_data, PyArrayObject* matrix_ar,
         PyArrayObject* shift_ar, PyArrayObject *coordinates,
         PyArrayObject *output, int order, int mode, double cval)
@@ -440,7 +440,7 @@
   for(jj = 0; jj < irank; jj++)
     ftmp[jj] = 0;
   kk = 0;
-  for(hh = 0; hh < filter_size; hh++) {    
+  for(hh = 0; hh < filter_size; hh++) {
     for(jj = 0; jj < irank; jj++)
       fcoordinates[jj + hh * irank] = ftmp[jj];
     foffsets[hh] = kk;
@@ -497,7 +497,7 @@
         CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float32);
         CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float64);
       default:
-        PyErr_SetString(PyExc_RuntimeError, 
+        PyErr_SetString(PyExc_RuntimeError,
                         "coordinate array data type not supported");
         goto exit;
       }
@@ -551,17 +551,17 @@
       }
     }
 
-    if (!constant) {                                                         
-      maybelong *ff = fcoordinates;               
-      for(hh = 0; hh < filter_size; hh++) {                           
+    if (!constant) {
+      maybelong *ff = fcoordinates;
+      for(hh = 0; hh < filter_size; hh++) {
         int idx = 0;
-        if (edge) {                                                         
-          for(ll = 0; ll < irank; ll++) { 
-            if (edge_offsets[ll])                 
-              idx += edge_offsets[ll][ff[ll]];         
-            else                                                         
+        if (edge) {
+          for(ll = 0; ll < irank; ll++) {
+            if (edge_offsets[ll])
+              idx += edge_offsets[ll][ff[ll]];
+            else
               idx += ff[ll] * istrides[ll];
-          }        
+          }
         } else {
           idx = foffsets[hh];
         }
@@ -570,36 +570,36 @@
         ff += irank;
       }
     }
-    if (!constant) {                                                         
-      maybelong *ff = fcoordinates;               
+    if (!constant) {
+      maybelong *ff = fcoordinates;
       t = 0.0;
-      for(hh = 0; hh < filter_size; hh++) {                           
+      for(hh = 0; hh < filter_size; hh++) {
         double coeff = 0.0;
         switch(input->descr->type_num) {
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool);       
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32);       
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32);
 #if HAS_UINT64
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); 
-#endif       
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64);        
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64);
+#endif
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64);
+          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");
           goto exit;
         }
         /* calculate the interpolated value: */
         for(ll = 0; ll < irank; ll++)
-          if (order > 0)                                                 
+          if (order > 0)
             coeff *= splvals[ll][ff[ll]];
-        t += coeff;                                                         
+        t += coeff;
         ff += irank;
-      }                                                                 
+      }
     } else {
       t = cval;
     }
@@ -630,7 +630,7 @@
   }
 
  exit:
-  if (edge_offsets) 
+  if (edge_offsets)
     free(edge_offsets);
   if (data_offsets) {
     for(jj = 0; jj < irank; jj++)
@@ -651,13 +651,13 @@
   return PyErr_Occurred() ? 0 : 1;
 }
 
-int NI_ZoomShift(PyArrayObject *input, PyArrayObject* zoom_ar, 
+int NI_ZoomShift(PyArrayObject *input, PyArrayObject* zoom_ar,
                  PyArrayObject* shift_ar, PyArrayObject *output,
                  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 ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL;
   maybelong jj, hh, kk, filter_size, odimensions[MAXDIM];
   maybelong idimensions[MAXDIM], istrides[MAXDIM], *idxs = NULL;
   maybelong size;
@@ -666,7 +666,7 @@
   Float64 *zooms = zoom_ar ? (Float64*)PyArray_DATA(zoom_ar) : NULL;
   Float64 *shifts = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL;
   int rank = 0, qq;
-  
+
   for(kk = 0; kk < input->nd; kk++) {
     idimensions[kk] = input->dimensions[kk];
     istrides[kk] = input->strides[kk];
@@ -688,10 +688,10 @@
       if(!zeros[jj]) {
         PyErr_NoMemory();
         goto exit;
-      }    
+      }
     }
   }
-  
+
   /* store offsets, along each axis: */
   offsets = (maybelong**)malloc(rank * sizeof(maybelong*));
   /* store spline coefficients, along each axis: */
@@ -714,7 +714,7 @@
     if (!offsets[jj] || !splvals[jj] || !edge_offsets[jj]) {
       PyErr_NoMemory();
       goto exit;
-    }  
+    }
     for(hh = 0; hh < odimensions[jj]; hh++) {
       splvals[jj][hh] = NULL;
       edge_offsets[jj][hh] = NULL;
@@ -775,9 +775,9 @@
           if (!splvals[jj][kk]) {
             PyErr_NoMemory();
             goto exit;
-          }        
+          }
           spline_coefficients(cc, order, splvals[jj][kk]);
-        }        
+        }
       } else {
         zeros[jj][kk] = 1;
       }
@@ -798,7 +798,7 @@
 
   pi = (void *)PyArray_DATA(input);
   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));
@@ -810,7 +810,7 @@
   for(jj = 0; jj < rank; jj++)
     ftmp[jj] = 0;
   kk = 0;
-  for(hh = 0; hh < filter_size; hh++) {    
+  for(hh = 0; hh < filter_size; hh++) {
     for(jj = 0; jj < rank; jj++)
       fcoordinates[jj + hh * rank] = ftmp[jj];
     foffsets[hh] = kk;
@@ -828,31 +828,31 @@
   size = 1;
   for(qq = 0; qq < output->nd; qq++)
     size *= output->dimensions[qq];
-  for(kk = 0; kk < size; kk++) {                                         
-    double t = 0.0;                                                         
+  for(kk = 0; kk < size; kk++) {
+    double t = 0.0;
     int edge = 0, oo = 0, zero = 0;
-                                                                         
-    for(hh = 0; hh < rank; hh++) {                                         
-      if (zeros && zeros[hh][io.coordinates[hh]]) { 
+
+    for(hh = 0; hh < rank; hh++) {
+      if (zeros && zeros[hh][io.coordinates[hh]]) {
         /* we use constant border condition */
-        zero = 1;                                                         
-        break;                                                         
-      }                                                                 
-      oo += offsets[hh][io.coordinates[hh]];                                 
-      if (edge_offsets[hh][io.coordinates[hh]])                         
-        edge = 1;                                                         
-    }                                                                         
-      
-    if (!zero) {                                                         
+        zero = 1;
+        break;
+      }
+      oo += offsets[hh][io.coordinates[hh]];
+      if (edge_offsets[hh][io.coordinates[hh]])
+        edge = 1;
+    }
+
+    if (!zero) {
       maybelong *ff = fcoordinates;
       for(hh = 0; hh < filter_size; hh++) {
-        int idx = 0;        
+        int idx = 0;
         if (edge) {
             /* use precalculated edge offsets: */
-          for(jj = 0; jj < rank; jj++) {                                 
-            if (edge_offsets[jj][io.coordinates[jj]])                 
-              idx += edge_offsets[jj][io.coordinates[jj]][ff[jj]];         
-            else                                                         
+          for(jj = 0; jj < rank; jj++) {
+            if (edge_offsets[jj][io.coordinates[jj]])
+              idx += edge_offsets[jj][io.coordinates[jj]][ff[jj]];
+            else
               idx += ff[jj] * istrides[jj];
           }
           idx += oo;
@@ -864,39 +864,39 @@
         ff += rank;
       }
     }
-    if (!zero) {                                                         
+    if (!zero) {
       maybelong *ff = fcoordinates;
       t = 0.0;
       for(hh = 0; hh < filter_size; hh++) {
         double coeff = 0.0;
         switch(input->descr->type_num) {
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool);       
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32);       
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32);
 #if HAS_UINT64
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); 
-#endif                                
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32);        
-          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64);        
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64);
+#endif
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32);
+          CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64);
+          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");
           goto exit;
         }
         /* calculate interpolated value: */
-        for(jj = 0; jj < rank; jj++)                 
-          if (order > 0)                                                 
-            coeff *= splvals[jj][io.coordinates[jj]][ff[jj]];         
-        t += coeff;                                                         
+        for(jj = 0; jj < rank; jj++)
+          if (order > 0)
+            coeff *= splvals[jj][io.coordinates[jj]][ff[jj]];
+        t += coeff;
         ff += rank;
-      }                                                 
+      }
     } else {
       t = cval;
-    }                
+    }
     /* store output: */
     switch (output->descr->type_num) {
       CASE_INTERP_OUT(po, t, Bool);
@@ -917,7 +917,7 @@
       goto exit;
     }
     NI_ITERATOR_NEXT(io, po);
-  }                                                                         
+  }
 
  exit:
   if (zeros) {

Modified: trunk/Lib/ndimage/src/ni_interpolation.h
===================================================================
--- trunk/Lib/ndimage/src/ni_interpolation.h	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_interpolation.h	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef NI_INTERPOLATION_H

Modified: trunk/Lib/ndimage/src/ni_measure.c
===================================================================
--- trunk/Lib/ndimage/src/ni_measure.c	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_measure.c	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "ni_support.h"
@@ -63,14 +63,14 @@
   ssize = 1;
   for(kk = 0; kk < strct->nd; kk++)
     ssize *= strct->dimensions[kk];
-  /* we only use the first half of the structure data, so we make a 
+  /* we only use the first half of the structure data, so we make a
      temporary structure for use with the filter functions: */
   footprint = (Bool*)malloc(ssize * sizeof(Bool));
   if (!footprint) {
     PyErr_NoMemory();
     goto exit;
   }
-  ps = (Bool*)NA_OFFSETDATA(strct);
+  ps = (Bool*)PyArray_DATA(strct);
   filter_size = 0;
   for(jj = 0; jj < ssize / 2; jj++) {
     footprint[jj] = ps[jj];
@@ -80,8 +80,8 @@
   for(jj = ssize / 2; jj < ssize; jj++)
     footprint[jj] = 0;
   /* get data and size */
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(kk = 0; kk < output->nd; kk++)
     size *= output->dimensions[kk];
@@ -119,12 +119,12 @@
                           NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL))
     goto exit;
   /* initialize filter iterator: */
-  if (!NI_InitFilterIterator(input->nd, strct->dimensions, filter_size, 
+  if (!NI_InitFilterIterator(input->nd, strct->dimensions, filter_size,
                                            input->dimensions, NULL, &fi))
     goto exit;
   /* reset output iterator: */
   NI_ITERATOR_RESET(io);
-  po = NA_OFFSETDATA(output);
+  po = (void *)PyArray_DATA(output);
   /* iterator over the elements: */
   oo = offsets;
   for(jj = 0; jj < size; jj++) {
@@ -185,7 +185,7 @@
       Int32 idx1 = pairs->index1 - 1;
       Int32 idx2 = pairs->index2 - 1;
       if (index_map[idx2] == idx1 || index_map[idx2] == idx2) {
-        /* if this pair was already processed, or if idx2 was not 
+        /* if this pair was already processed, or if idx2 was not
            mapped yet, we delete this pair and map idx2 to idx1: */
         _index_pair *tp = pairs;
         pairs = tp->next;
@@ -228,7 +228,7 @@
   if (index_map) {
     *max_label = 0;
     NI_ITERATOR_RESET(io);
-    po = NA_OFFSETDATA(output);
+    po = (void *)PyArray_DATA(output);
     for(jj = 0; jj < size; jj++) {
       Int32 p = *(Int32*)po;
       if (p > 0 )
@@ -291,7 +291,7 @@
   char *pi;
 
   /* get input data, size and iterator: */
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
   size = 1;
   for(kk = 0; kk < input->nd; kk++)
     size *= input->dimensions[kk];
@@ -307,25 +307,25 @@
   /* iterate over all points: */
   for(jj = 0 ; jj < size; jj++) {
     switch (input->descr->type_num) {
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii,  Bool);
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, UInt8);
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, UInt16);
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, UInt32);
 #if HAS_UINT64
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, UInt64);
 #endif
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, Int8);
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, Int16);
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, Int32);
-    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, 
+    CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions,
                            max_label, ii, Int64);
       break;
     default:
@@ -511,8 +511,8 @@
 }
 #endif
 
-int NI_Statistics(PyArrayObject *input, PyArrayObject *labels, 
-  maybelong min_label, maybelong max_label, maybelong *indices, 
+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)
 {
@@ -520,16 +520,16 @@
   NI_Iterator ii, mi;
   maybelong jj, size, idx = 0, label = 1, doit = 1;
   int qq;
-  
+
   /* input iterator: */
   if (!NI_InitPointIterator(input, &ii))
     return 0;
   /* input data: */
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
   if (labels) {
     if (!NI_InitPointIterator(labels, &mi))
       return 0;
-    pm = NA_OFFSETDATA(labels);
+    pm = (void *)PyArray_DATA(labels);
   }
   /* input size: */
   size = 1;
@@ -560,7 +560,7 @@
         doit = idx >= 0;
       } else {
         doit = 0;
-      } 
+      }
     } else {
       doit = label != 0;
     }
@@ -610,11 +610,11 @@
     if (do_var) {
       /* reset input iterator: */
       NI_ITERATOR_RESET(ii);
-      pi = NA_OFFSETDATA(input);
+      pi = (void *)PyArray_DATA(input);
       if (labels) {
         /* reset label iterator: */
         NI_ITERATOR_RESET(mi);
-        pm = NA_OFFSETDATA(labels);
+        pm = (void *)PyArray_DATA(labels);
       }
       for(jj = 0; jj < size; jj++) {
         NI_GET_LABEL(pm, label, labels->descr->type_num);
@@ -624,7 +624,7 @@
             doit = idx >= 0;
           } else {
             doit = 0;
-          } 
+          }
         } else {
           doit = label != 0;
         }
@@ -641,7 +641,7 @@
         }
       }
       for(jj = 0; jj < n_results; jj++)
-        variance[jj] = (total[jj] > 1 ? 
+        variance[jj] = (total[jj] > 1 ?
                         variance[jj] / (total[jj] - 1) : 0.0);
     }
   }
@@ -649,8 +649,8 @@
 }
 
 
-int NI_CenterOfMass(PyArrayObject *input, PyArrayObject *labels, 
-              maybelong min_label, maybelong max_label, maybelong *indices, 
+int NI_CenterOfMass(PyArrayObject *input, PyArrayObject *labels,
+              maybelong min_label, maybelong max_label, maybelong *indices,
               maybelong n_results, double *center_of_mass)
 {
   char *pi = NULL, *pm = NULL;
@@ -663,11 +663,11 @@
   if (!NI_InitPointIterator(input, &ii))
     goto exit;
   /* input data: */
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
   if (labels) {
     if (!NI_InitPointIterator(labels, &mi))
       goto exit;
-    pm = NA_OFFSETDATA(labels);
+    pm = (void *)PyArray_DATA(labels);
   }
   /* input size: */
   size = 1;
@@ -692,7 +692,7 @@
         doit = idx >= 0;
       } else {
         doit = 0;
-      } 
+      }
     } else {
       doit = label != 0;
     }
@@ -719,8 +719,8 @@
 }
 
 
-int NI_Histogram(PyArrayObject *input, PyArrayObject *labels, 
-              maybelong min_label, maybelong max_label, maybelong *indices, 
+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)
 {
@@ -730,16 +730,16 @@
   Int32 **ph = NULL;
   double bsize;
   int qq;
-  
+
   /* input iterator: */
   if (!NI_InitPointIterator(input, &ii))
     goto exit;
   /* input data: */
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
   if (labels) {
     if (!NI_InitPointIterator(labels, &mi))
       goto exit;
-    pm = NA_OFFSETDATA(labels);
+    pm = (void *)PyArray_DATA(labels);
   }
   ph = (Int32**)malloc(n_results * sizeof(Int32*));
   if (!ph) {
@@ -747,9 +747,9 @@
     goto exit;
   }
   for(jj = 0; jj < n_results; jj++) {
-    ph[jj] = (Int32*)NA_OFFSETDATA(histograms[jj]);
-    for(kk = 0; kk < nbins; kk++)
-      ph[jj][kk] = 0;
+      ph[jj] = (Int32*)PyArray_DATA(histograms[jj]);
+      for(kk = 0; kk < nbins; kk++)
+          ph[jj][kk] = 0;
   }
   bsize = (max - min) / (double)nbins;
   /* input size: */
@@ -765,7 +765,7 @@
         doit = idx >= 0;
       } else {
         doit = 0;
-      } 
+      }
     } else {
       doit = label != 0;
     }
@@ -821,7 +821,7 @@
 case t ## _type:                           \
   *((_type*)_pl) = _label;                 \
   break
-  
+
 #define CASE_WINDEX1(_v_index, _p_index, _strides, _istrides, _irank,  \
                      _icont, _p_idx, _v_idx, _pi, _vval, _pval, _type) \
 case t ## _type:                                                       \
@@ -860,7 +860,7 @@
   DONE_TYPE done;
 } NI_WatershedElement;
 
-int NI_WatershedIFT(PyArrayObject* input, PyArrayObject* markers, 
+int NI_WatershedIFT(PyArrayObject* input, PyArrayObject* markers,
                     PyArrayObject* strct, PyArrayObject* output)
 {
   char *pl, *pm, *pi;
@@ -872,7 +872,7 @@
   NI_WatershedElement *temp = NULL, **first = NULL, **last = NULL;
   Bool *ps = NULL;
   NI_Iterator mi, ii, li;
-  
+
   i_contiguous = PyArray_ISCONTIGUOUS(input);
   o_contiguous = PyArray_ISCONTIGUOUS(output);
   ssize = 1;
@@ -891,7 +891,7 @@
     PyErr_NoMemory();
     goto exit;
   }
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
   if (!NI_InitPointIterator(input, &ii))
     goto exit;
   /* Initialization and find the maximum of the input. */
@@ -911,11 +911,11 @@
       maxval = ival;
     NI_ITERATOR_NEXT(ii, pi);
   }
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
   /* Allocate and initialize the storage for the queue. */
-  first = (NI_WatershedElement**)malloc((maxval + 1) * 
+  first = (NI_WatershedElement**)malloc((maxval + 1) *
                                         sizeof(NI_WatershedElement*));
-  last = (NI_WatershedElement**)malloc((maxval + 1) * 
+  last = (NI_WatershedElement**)malloc((maxval + 1) *
                                        sizeof(NI_WatershedElement*));
   if (!first || !last) {
     PyErr_NoMemory();
@@ -929,15 +929,15 @@
     goto exit;
   if (!NI_InitPointIterator(output, &li))
     goto exit;
-  pm = NA_OFFSETDATA(markers);
-  pl = NA_OFFSETDATA(output);
+  pm = (void *)PyArray_DATA(markers);
+  pl = (void *)PyArray_DATA(output);
   /* initialize all nodes */
   for(ll = 0; ll < input->nd; ll++)
     coordinates[ll] = 0;
   for(jj = 0; jj < size; jj++) {
     /* get marker */
     int label = 0;
-    switch(markers->descr->type_num) { 
+    switch(markers->descr->type_num) {
     CASE_GET_LABEL(label, pm, UInt8);
     CASE_GET_LABEL(label, pm, UInt16);
     CASE_GET_LABEL(label, pm, UInt32);
@@ -1001,15 +1001,15 @@
     }
     for(ll = input->nd - 1; ll >= 0; ll--)
       if (coordinates[ll] < input->dimensions[ll] - 1) {
-        coordinates[ll]++;                        
-        break;                                                
-      } else {                                                
-        coordinates[ll] = 0;                        
-      }        
+        coordinates[ll]++;
+        break;
+      } else {
+        coordinates[ll] = 0;
+      }
   }
-  
-  pl = NA_OFFSETDATA(output);
-  ps = (Bool*)NA_OFFSETDATA(strct);
+
+  pl = (void *)PyArray_DATA(output);
+  ps = (Bool*)PyArray_DATA(strct);
   nneigh = 0;
   for (kk = 0; kk < ssize; kk++)
     if (ps[kk] && kk != (ssize / 2))
@@ -1037,11 +1037,11 @@
     }
     for(ll = input->nd - 1; ll >= 0; ll--)
       if (coordinates[ll] < 1) {
-        coordinates[ll]++;                        
-        break;                                                
-      } else {                                                
-        coordinates[ll] = -1;                        
-      }        
+        coordinates[ll]++;
+        break;
+      } else {
+        coordinates[ll] = -1;
+      }
   }
   /* Propagation phase: */
   for(jj = 0; jj <= maxval; jj++) {
@@ -1076,11 +1076,11 @@
             /* If the neighbor was not processed yet: */
             int max, pval, vval, wvp, pcost, label, p_idx, v_idx;
             switch(input->descr->type_num) {
-            CASE_WINDEX1(v_index, p_index, strides, input->strides, 
-                         input->nd, i_contiguous, p_idx, v_idx, pi, 
+            CASE_WINDEX1(v_index, p_index, strides, input->strides,
+                         input->nd, i_contiguous, p_idx, v_idx, pi,
                          vval, pval, UInt8);
-            CASE_WINDEX1(v_index, p_index, strides, input->strides, 
-                         input->nd, i_contiguous, p_idx, v_idx, pi, 
+            CASE_WINDEX1(v_index, p_index, strides, input->strides,
+                         input->nd, i_contiguous, p_idx, v_idx, pi,
                          vval, pval, UInt16);
             default:
               PyErr_SetString(PyExc_RuntimeError,
@@ -1091,7 +1091,7 @@
             wvp = pval - vval;
             if (wvp < 0)
               wvp = -wvp;
-            /* Find the maximum of this cost and the current 
+            /* Find the maximum of this cost and the current
                element cost: */
             pcost = p->cost;
             max = v->cost > wvp ? v->cost : wvp;
@@ -1157,7 +1157,7 @@
                   last[pcost] = prev;
                 if (prev)
                   prev->next = next;
-                if (next) 
+                if (next)
                   next->prev = prev;
               }
               /* Insert the neighbor in the appropiate queue: */

Modified: trunk/Lib/ndimage/src/ni_morphology.c
===================================================================
--- trunk/Lib/ndimage/src/ni_morphology.c	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_morphology.c	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "ni_support.h"
@@ -41,7 +41,7 @@
 #define CASE_GET_MASK(_msk_value, _pm, _type) \
 case t ## _type:                              \
   _msk_value = *(_type*)_pm ? 1 : 0;          \
-  break                        
+  break
 
 #define CASE_OUTPUT(_po, _out, _type) \
 case t ## _type:                      \
@@ -84,30 +84,30 @@
 }                                                                     \
 break
 
-int NI_BinaryErosion(PyArrayObject* input, PyArrayObject* strct, 
+int NI_BinaryErosion(PyArrayObject* input, PyArrayObject* strct,
         PyArrayObject* mask, PyArrayObject* output, int bdr_value,
-        maybelong *origins, int invert, int center_is_true, int* changed, 
+        maybelong *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;
-  int kk, true, false, msk_value;  
+  int kk, true, false, msk_value;
   NI_Iterator ii, io, mi;
   NI_FilterIterator fi;
   Bool *ps, out = 0;
   char *pi, *po, *pm = NULL;
   NI_CoordinateBlock *block = NULL;
 
-  ps = (Bool*)NA_OFFSETDATA(strct);
+  ps = (Bool*)PyArray_DATA(strct);
   ssize = 1;
   for(kk = 0; kk < strct->nd; kk++)
     ssize *= strct->dimensions[kk];
-  for(jj = 0; jj < ssize; jj++) 
+  for(jj = 0; jj < ssize; jj++)
     if (ps[jj]) ++struct_size;
   if (mask) {
     if (!NI_InitPointIterator(mask, &mi))
       return 0;
-    pm = NA_OFFSETDATA(mask);
+    pm = (void *)PyArray_DATA(mask);
   }
   /* calculate the filter offsets: */
   if (!NI_InitFilterOffsets(input, ps, strct->dimensions, origins,
@@ -123,10 +123,10 @@
   if (!NI_InitFilterIterator(input->nd, strct->dimensions, struct_size,
                              input->dimensions, origins, &fi))
     goto exit;
-    
+
   /* get data pointers an size: */
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
   size = 1;
   for(kk = 0; kk < input->nd; kk++)
     size *= input->dimensions[kk];
@@ -155,8 +155,8 @@
   msk_value = 1;
   for(jj = 0; jj < size; jj++) {
     int pchange = 0;
-    if (mask) {                                                        
-      switch(mask->descr->type_num) {                                                
+    if (mask) {
+      switch(mask->descr->type_num) {
       CASE_GET_MASK(msk_value, pm, Bool);
       CASE_GET_MASK(msk_value, pm, UInt8);
       CASE_GET_MASK(msk_value, pm, UInt16);
@@ -170,10 +170,10 @@
       CASE_GET_MASK(msk_value, pm, Int64);
       CASE_GET_MASK(msk_value, pm, Float32);
       CASE_GET_MASK(msk_value, pm, Float64);
-      default:                        
-        PyErr_SetString(PyExc_RuntimeError, "data type not supported");        
-        return 0; 
-      }        
+      default:
+        PyErr_SetString(PyExc_RuntimeError, "data type not supported");
+        return 0;
+      }
     }
     switch (input->descr->type_num) {
     CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Bool, msk_value,
@@ -182,14 +182,14 @@
     CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt8, msk_value,
                         bdr_value, border_flag_value, center_is_true,
                         true, false, pchange);
-    CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt16, msk_value, 
-                        bdr_value, border_flag_value, center_is_true, 
+    CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt16, msk_value,
+                        bdr_value, border_flag_value, center_is_true,
                         true, false, pchange);
     CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt32, msk_value,
                         bdr_value, border_flag_value, center_is_true,
                         true, false, pchange);
 #if HAS_UINT64
-    CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt64, msk_value, 
+    CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt64, msk_value,
                         bdr_value, border_flag_value, center_is_true,
                         true, false, pchange);
 #endif
@@ -205,7 +205,7 @@
     CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int64, msk_value,
                         bdr_value, border_flag_value, center_is_true,
                         true, false, pchange);
-    CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float32, msk_value, 
+    CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float32, msk_value,
                         bdr_value, border_flag_value, center_is_true,
                         true, false, pchange);
     CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float64, msk_value,
@@ -253,7 +253,7 @@
   }
 
  exit:
-  if (offsets) 
+  if (offsets)
     free(offsets);
   if (PyErr_Occurred()) {
     if (coordinate_list) {
@@ -310,11 +310,11 @@
   NI_CoordinateBlock *block1 = NULL, *block2 = NULL;
   NI_CoordinateList *list1 = NULL, *list2 = NULL;
 
-  ps = (Bool*)NA_OFFSETDATA(strct);
+  ps = (Bool*)PyArray_DATA(strct);
   ssize = 1;
   for(kk = 0; kk < strct->nd; kk++)
     ssize *= strct->dimensions[kk];
-  for(jj = 0; jj < ssize; jj++) 
+  for(jj = 0; jj < ssize; jj++)
     if (ps[jj]) ++struct_size;
 
   /* calculate the filter offsets: */
@@ -322,22 +322,22 @@
                             NI_EXTEND_CONSTANT, &offsets,
                             &border_flag_value, &coordinate_offsets))
     goto exit;
-      
+
   /* initialize input element iterator: */
   if (!NI_InitPointIterator(array, &ii))
     goto exit;
 
   /* initialize filter iterator: */
-  if (!NI_InitFilterIterator(array->nd, strct->dimensions, struct_size, 
+  if (!NI_InitFilterIterator(array->nd, strct->dimensions, struct_size,
                              array->dimensions, origins, &fi))
     goto exit;
   if (!NI_InitFilterIterator(array->nd, strct->dimensions,
                              struct_size * array->nd, array->dimensions,
                              origins, &ci))
     goto exit;
-    
+
   /* get data pointers and size: */
-  ibase = pi = NA_OFFSETDATA(array);
+  ibase = pi = (void *)PyArray_DATA(array);
 
   if (invert) {
     true = 0;
@@ -351,7 +351,7 @@
     /* iterator, data pointer and type of mask array: */
     if (!NI_InitPointIterator(mask, &mi))
       return 0;
-    pm = NA_OFFSETDATA(mask);
+    pm = (void *)PyArray_DATA(mask);
 
     size = 1;
     for(kk = 0; kk < array->nd; kk++)
@@ -364,12 +364,12 @@
         *(Int8*)pm = (Int8)*(Bool*)pi;
         *(Bool*)pi = false;
       }
-      NI_ITERATOR_NEXT2(ii, mi,  pi, pm)    
+      NI_ITERATOR_NEXT2(ii, mi,  pi, pm)
     }
     NI_ITERATOR_RESET(ii)
-    pi = NA_OFFSETDATA(array);
+        pi = (void *)PyArray_DATA(array);
   }
-  
+
   list1 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank);
   list2 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank);
   if (!list1 || !list2)
@@ -388,61 +388,61 @@
         block2 = NULL;
         current_coordinates1 = block1->coordinates;
         current = 0;
-        ++jj;      
-        mklist = niter <= 0 || jj < niter;   
+        ++jj;
+        mklist = niter <= 0 || jj < niter;
       } else {
         break;
-      }      
+      }
     }
     NI_ITERATOR_GOTO(ii, current_coordinates1, ibase, pi);
     NI_FILTER_GOTO(fi, ii, 0, oo);
 
     switch (array->descr->type_num) {
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, Bool, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, UInt8, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, UInt16, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, UInt32, mklist);
 #if HAS_UINT64
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, UInt64, mklist);
 #endif
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, Int8, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, Int16, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, Int32, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, Int64, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, Float32, mklist);
     CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi,
-                      oo, array->nd, list1, list2, current_coordinates1, 
-                      current_coordinates2, block1, block2, 
+                      oo, array->nd, list1, list2, current_coordinates1,
+                      current_coordinates2, block1, block2,
                       border_flag_value, true, false, Float64, mklist);
     default:
       PyErr_SetString(PyExc_RuntimeError, "data type not supported");
@@ -460,22 +460,22 @@
       current_coordinates1 += array->nd;
     }
   }
-  
+
   if (mask) {
     NI_ITERATOR_RESET(ii)
     NI_ITERATOR_RESET(mi)
-    pi = NA_OFFSETDATA(array);
-    pm = NA_OFFSETDATA(mask);
+    pi = (void *)PyArray_DATA(array);
+    pm = (void *)PyArray_DATA(mask);
     for(jj = 0; jj < size; jj++) {
       int value = *(Int8*)pm;
       if (value >= 0)
         *(Bool*)pi = value;
-      NI_ITERATOR_NEXT2(ii, mi,  pi, pm)    
+      NI_ITERATOR_NEXT2(ii, mi,  pi, pm)
     }
   }
 
  exit:
-  if (offsets) 
+  if (offsets)
     free(offsets);
   if (coordinate_offsets)
     free(coordinate_offsets);
@@ -501,8 +501,8 @@
 } NI_BorderElement;
 
 int NI_DistanceTransformBruteForce(PyArrayObject* input, int metric,
-                                   PyArrayObject *sampling_arr, 
-                                   PyArrayObject* distances, 
+                                   PyArrayObject *sampling_arr,
+                                   PyArrayObject* distances,
                                    PyArrayObject* features)
 {
   maybelong size, jj, min_index = 0;
@@ -510,17 +510,17 @@
   NI_BorderElement *border_elements = NULL, *temp;
   NI_Iterator ii, di, fi;
   char *pi, *pd = NULL, *pf = NULL;
-  Float64 *sampling = sampling_arr ? NA_OFFSETDATA(sampling_arr) : NULL;
-  
+  Float64 *sampling = sampling_arr ? (void *)PyArray_DATA(sampling_arr) : NULL;
+
   /* check the output arrays: */
   if (distances) {
-    pd = NA_OFFSETDATA(distances);
+      pd = (void *)PyArray_DATA(distances);
     if (!NI_InitPointIterator(distances, &di))
       goto exit;
   }
 
   if (features) {
-    pf = NA_OFFSETDATA(features);
+      pf = (void *)PyArray_DATA(features);
     if (!NI_InitPointIterator(features, &fi))
       goto exit;
   }
@@ -528,11 +528,11 @@
   size = 1;
   for(kk = 0; kk < input->nd; kk++)
     size *= input->dimensions[kk];
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
 
   if (!NI_InitPointIterator(input, &ii))
     goto exit;
-  
+
   for(jj = 0; jj < size; jj++) {
     if (*(Int8*)pi < 0) {
       temp = (NI_BorderElement*)malloc(sizeof(NI_BorderElement));
@@ -545,13 +545,13 @@
       temp->index = jj;
       temp->coordinates = (maybelong*)malloc(input->nd * sizeof(maybelong));
       for(kk = 0; kk < input->nd; kk++)
-	temp->coordinates[kk] = ii.coordinates[kk];
+          temp->coordinates[kk] = ii.coordinates[kk];
     }
     NI_ITERATOR_NEXT(ii, pi);
   }
 
   NI_ITERATOR_RESET(ii);
-  pi = NA_OFFSETDATA(input);
+  pi = (void *)PyArray_DATA(input);
 
   switch(metric) {
   case NI_DISTANCE_EUCLIDIAN:
@@ -574,12 +574,12 @@
           }
           temp = temp->next;
         }
-        if (distances) 
+        if (distances)
           *(Float64*)pd = sqrt(distance);
         if (features)
           *(Int32*)pf = min_index;
       } else {
-        if (distances) 
+        if (distances)
           *(Float64*)pd = 0.0;
         if (features)
           *(Int32*)pf = jj;
@@ -620,12 +620,12 @@
           }
           temp = temp->next;
         }
-        if (distances) 
+        if (distances)
           *(UInt32*)pd = distance;
         if (features)
           *(Int32*)pf = min_index;
       } else {
-        if (distances) 
+        if (distances)
           *(UInt32*)pd = 0;
         if (features)
           *(Int32*)pf = jj;
@@ -659,7 +659,7 @@
 int NI_DistanceTransformOnePass(PyArrayObject *strct,
                         PyArrayObject* distances, PyArrayObject *features)
 {
-  int kk; 
+  int kk;
   maybelong jj, ii, ssize, size, filter_size, mask_value, *oo;
   maybelong *foffsets = NULL, *foo = NULL, *offsets = NULL;
   Bool *ps, *pf = NULL, *footprint = NULL;
@@ -671,14 +671,14 @@
   for(kk = 0; kk < strct->nd; kk++)
     ssize *= strct->dimensions[kk];
 
-  /* we only use the first half of the structure data, so we make a 
+  /* we only use the first half of the structure data, so we make a
      temporary structure for use with the filter functions: */
   footprint = (Bool*)malloc(ssize * sizeof(Bool));
   if (!footprint) {
     PyErr_NoMemory();
     goto exit;
   }
-  ps = (Bool*)NA_OFFSETDATA(strct);
+  ps = (Bool*)PyArray_DATA(strct);
   filter_size = 0;
   for(jj = 0; jj < ssize / 2; jj++) {
     footprint[jj] = ps[jj];
@@ -688,25 +688,25 @@
   for(jj = ssize / 2; jj < ssize; jj++)
     footprint[jj] = 0;
   /* get data and size */
-  pd = NA_OFFSETDATA(distances);
+  pd = (void *)PyArray_DATA(distances);
   size = 1;
   for(kk = 0; kk < distances->nd; kk++)
     size *= distances->dimensions[kk];
   if (!NI_InitPointIterator(distances, &di))
     goto exit;
   /* calculate the filter offsets: */
-  if (!NI_InitFilterOffsets(distances, footprint, strct->dimensions, NULL, 
+  if (!NI_InitFilterOffsets(distances, footprint, strct->dimensions, NULL,
                           NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL))
     goto exit;
   /* initialize filter iterator: */
-  if (!NI_InitFilterIterator(distances->nd, strct->dimensions, 
+  if (!NI_InitFilterIterator(distances->nd, strct->dimensions,
                           filter_size, distances->dimensions, NULL, &si))
     goto exit;
-  
+
   if (features) {
     maybelong dummy;
     /* initialize point iterator: */
-    pf = NA_OFFSETDATA(features);
+    pf = (void *)PyArray_DATA(features);
     if (!NI_InitPointIterator(features, &fi))
       goto exit;
     /* calculate the filter offsets: */
@@ -714,7 +714,7 @@
                         NULL, NI_EXTEND_CONSTANT, &foffsets, &dummy, NULL))
       goto exit;
     /* initialize filter iterator: */
-    if (!NI_InitFilterIterator(distances->nd, strct->dimensions, 
+    if (!NI_InitFilterIterator(distances->nd, strct->dimensions,
                            filter_size, distances->dimensions, NULL, &ti))
       goto exit;
   }
@@ -750,7 +750,7 @@
     }
     NI_FILTER_NEXT(si, di, oo, pd);
   }
-  
+
  exit:
   if (offsets) free(offsets);
   if (foffsets) free(foffsets);
@@ -760,12 +760,12 @@
 }
 
 static void _VoronoiFT(char *pf, maybelong len, maybelong *coor, int rank,
-                       int d, maybelong stride, maybelong cstride, 
+                       int d, maybelong stride, maybelong cstride,
                        maybelong **f, maybelong *g, Float64 *sampling)
 {
   maybelong l = -1, ii, maxl, idx1, idx2;
   int jj;
-  
+
   for(ii = 0; ii < len; ii++)
     for(jj = 0; jj < rank; jj++)
       f[ii][jj] = *(Int32*)(pf + ii * stride + cstride * jj);
@@ -847,9 +847,9 @@
 
 
 /* Recursive feature transform */
-static void _ComputeFT(char *pi, char *pf, maybelong *ishape, 
+static void _ComputeFT(char *pi, char *pf, maybelong *ishape,
                        maybelong *istrides, maybelong *fstrides, int rank,
-                       int d, maybelong *coor, maybelong **f, maybelong *g, 
+                       int d, maybelong *coor, maybelong **f, maybelong *g,
                        PyArrayObject *features, Float64 *sampling)
 {
   int kk;
@@ -918,10 +918,10 @@
   maybelong coor[NI_MAXDIM], mx = 0, jj;
   maybelong *tmp = NULL, **f = NULL, *g = NULL;
   char *pi, *pf;
-  Float64 *sampling = sampling_arr ? NA_OFFSETDATA(sampling_arr) : NULL;
+  Float64 *sampling = sampling_arr ? ((void *)PyArray_DATA(sampling_arr)) : NULL;
 
-  pi = NA_OFFSETDATA(input);
-  pf = NA_OFFSETDATA(features);
+  pi = (void *)PyArray_DATA(input);
+  pf = (void *)PyArray_DATA(features);
   for(ii = 0; ii < input->nd; ii++) {
     coor[ii] = 0;
     if (input->dimensions[ii] > mx)
@@ -936,9 +936,9 @@
     PyErr_NoMemory();
     goto exit;
   }
-  for(jj = 0; jj < mx; jj++) 
+  for(jj = 0; jj < mx; jj++)
     f[jj] = tmp + jj * input->nd;
-  
+
   /* First call of recursive feature transform */
   _ComputeFT(pi, pf, input->dimensions, input->strides, features->strides,
              input->nd, input->nd - 1, coor, f, g, features, sampling);
@@ -950,6 +950,6 @@
     free(g);
   if (tmp)
     free(tmp);
-      
+
   return PyErr_Occurred() ? 0 : 1;
 }

Modified: trunk/Lib/ndimage/src/ni_support.c
===================================================================
--- trunk/Lib/ndimage/src/ni_support.c	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_support.c	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "ni_support.h"
@@ -45,7 +45,7 @@
     /* initialize strides: */
     iterator->strides[ii] = array->strides[ii];
     /* calculate the strides to move back at the end of an axis: */
-    iterator->backstrides[ii] = 
+    iterator->backstrides[ii] =
         array->strides[ii] * iterator->dimensions[ii];
   }
   return 1;
@@ -56,7 +56,7 @@
 int NI_SubspaceIterator(NI_Iterator *iterator, UInt32 axes)
 {
   int ii, last = 0;
-  
+
   for(ii = 0; ii <= iterator->rank_m1; ii++) {
     if (axes & (((UInt32)1) << ii)) {
       if (last != ii) {
@@ -84,7 +84,7 @@
 /******************************************************************/
 
 /* Allocate line buffer data */
-int NI_AllocateLineBuffer(PyArrayObject* array, int axis, maybelong size1, 
+int NI_AllocateLineBuffer(PyArrayObject* array, int axis, maybelong size1,
     maybelong size2, maybelong *lines, maybelong max_size, double **buffer)
 {
   maybelong line_size, max_lines;
@@ -104,7 +104,7 @@
      from the maximum size allowed: */
   if (*lines < 1) {
     *lines = line_size > 0 ? max_size / line_size : 0;
-    if (*lines < 1) 
+    if (*lines < 1)
       *lines = 1;
   }
   /* no need to allocate too many lines: */
@@ -120,13 +120,13 @@
 }
 
 /* Initialize a line buffer */
-int NI_InitLineBuffer(PyArrayObject *array, int axis, maybelong size1, 
+int NI_InitLineBuffer(PyArrayObject *array, int axis, maybelong size1,
     maybelong size2, maybelong buffer_lines, double *buffer_data,
     NI_ExtendMode extend_mode, double extend_value, NI_LineBuffer *buffer)
 {
   maybelong line_length = 0, array_lines = 0, size;
   int ii;
-  
+
   size = 1;
   for(ii = 0; ii < array->nd; ii++)
     size *= array->dimensions[ii];
@@ -144,7 +144,7 @@
   if (line_length > 0)
     array_lines = line_length > 0 ? size / line_length : 1;
   /* initialize the buffer structure: */
-  buffer->array_data = NA_OFFSETDATA(array);
+  buffer->array_data = (void *)PyArray_DATA(array);
   buffer->buffer_data = buffer_data;
   buffer->buffer_lines = buffer_lines;
   buffer->array_type = array->descr->type_num;
@@ -160,7 +160,7 @@
 }
 
 /* Extend a line in memory to implement boundary conditions: */
-int NI_ExtendLine(double *line, maybelong length, maybelong size1, 
+int NI_ExtendLine(double *line, maybelong length, maybelong size1,
                 maybelong size2, NI_ExtendMode mode, double constant_value)
 {
   maybelong ii, jj, length1, nextend, rextend;
@@ -174,25 +174,25 @@
     l2 = line;
     for(ii = 0; ii < rextend; ii++)
       *l2++ = *l1++;
-    for(ii = 0; ii < nextend; ii++) {                                        
+    for(ii = 0; ii < nextend; ii++) {
       l1 = line + size1;
       for(jj = 0; jj < length; jj++)
         *l2++ = *l1++;
-    }                                                                        
-    nextend = size2 / length;                        
-    rextend = size2 - nextend * length;                
-    l1 = line + size1;                
-    l2 = line + size1 + length;        
-    for(ii = 0; ii < nextend; ii++) {                        
-      l3 = l1;                                        
+    }
+    nextend = size2 / length;
+    rextend = size2 - nextend * length;
+    l1 = line + size1;
+    l2 = line + size1 + length;
+    for(ii = 0; ii < nextend; ii++) {
+      l3 = l1;
       for(jj = 0; jj < length; jj++)
         *l2++ = *l3++;
-    }                                                        
+    }
     for(ii = 0; ii < rextend; ii++)
       *l2++ = *l1++;
     break;
   case NI_EXTEND_MIRROR:
-    if (length == 1) {                
+    if (length == 1) {
       l1 = line;
       val = line[size1];
       for(ii = 0; ii < size1; ii++)
@@ -201,58 +201,58 @@
       val = line[size1 + length - 1];
       for(ii = 0; ii < size2; ii++)
         *l1++ = val;
-    } else {                                                                   
-      length1 = length - 1;                                
-      nextend = size1 / length1;                        
-      rextend = size1 - nextend * length1;                
-      l1 = line + size1 + 1;        
-      l2 = l1 - 2;                        
-      for(ii = 0; ii < nextend; ii++) {                        
-        l3 = l1;                                        
+    } else {
+      length1 = length - 1;
+      nextend = size1 / length1;
+      rextend = size1 - nextend * length1;
+      l1 = line + size1 + 1;
+      l2 = l1 - 2;
+      for(ii = 0; ii < nextend; ii++) {
+        l3 = l1;
         for(jj = 0; jj < length1; jj++)
           *l2-- = *l3++;
-        l1 -= length1;                                
-      }                                                        
+        l1 -= length1;
+      }
       for(ii = 0; ii < rextend; ii++)
         *l2-- = *l1++;
-      nextend = size2 / length1;                                
-      rextend = size2 - nextend * length1;                        
-      l1 = line + size1 + length1 - 1;        
-      l2 = l1 + 2;                                
-      for(ii = 0; ii < nextend; ii++) {                                
-        l3 = l1;                                                
-        for(jj = 0; jj < length1; jj++)                                
+      nextend = size2 / length1;
+      rextend = size2 - nextend * length1;
+      l1 = line + size1 + length1 - 1;
+      l2 = l1 + 2;
+      for(ii = 0; ii < nextend; ii++) {
+        l3 = l1;
+        for(jj = 0; jj < length1; jj++)
           *l2++ = *l3--;
-        l1 += length1;                                        
-      }                                                                
+        l1 += length1;
+      }
       for(ii = 0; ii < rextend; ii++)
         *l2++ = *l1--;
     }
     break;
   case NI_EXTEND_REFLECT:
-    nextend = size1 / length;                
-    rextend = size1 - nextend * length;        
-    l1 = line + size1;        
-    l2 = l1 - 1;                        
-    for(ii = 0; ii < nextend; ii++) {                
-      l3 = l1;                                        
+    nextend = size1 / length;
+    rextend = size1 - nextend * length;
+    l1 = line + size1;
+    l2 = l1 - 1;
+    for(ii = 0; ii < nextend; ii++) {
+      l3 = l1;
       for(jj = 0; jj < length; jj++)
         *l2-- = *l3++;
-      l1 -= length;                        
-    }                                                
-    l3 = l1;                                        
+      l1 -= length;
+    }
+    l3 = l1;
     for(ii = 0; ii < rextend; ii++)
       *l2-- = *l3++;
-    nextend = size2 / length;                                
-    rextend = size2 - nextend * length;                        
-    l1 = line + size1 + length - 1;        
-    l2 = l1 + 1;                                        
-    for(ii = 0; ii < nextend; ii++) {                                
-      l3 = l1;                                                
+    nextend = size2 / length;
+    rextend = size2 - nextend * length;
+    l1 = line + size1 + length - 1;
+    l2 = l1 + 1;
+    for(ii = 0; ii < nextend; ii++) {
+      l3 = l1;
       for(jj = 0; jj < length; jj++)
         *l2++ = *l3--;
-      l1 += length;                                        
-    }                                                                
+      l1 += length;
+    }
     for(ii = 0; ii < rextend; ii++)
       *l2++ = *l1--;
     break;
@@ -260,19 +260,19 @@
     l1 = line;
     val = line[size1];
     for(ii = 0; ii < size1; ii++)
-      *l1++ = val;                                        
-    l1 = line + size1 + length;                
+      *l1++ = val;
+    l1 = line + size1 + length;
     val = line[size1 + length - 1];
-    for(ii = 0; ii < size2; ii++)                                
+    for(ii = 0; ii < size2; ii++)
       *l1++ = val;
     break;
   case NI_EXTEND_CONSTANT:
     l1 = line;
     for(ii = 0; ii < size1; ii++)
-      *l1++ = constant_value;                                        
-    l1 = line + size1 + length;                
-    for(ii = 0; ii < size2; ii++)                                
       *l1++ = constant_value;
+    l1 = line + size1 + length;
+    for(ii = 0; ii < size2; ii++)
+      *l1++ = constant_value;
     break;
   default:
     PyErr_SetString(PyExc_RuntimeError, "mode not supported");
@@ -291,7 +291,7 @@
     _pi += _stride;                                               \
   }                                                               \
 }                                                                 \
-break                                                   
+break
 
 
 /* Copy a line from an array to a buffer: */
@@ -332,14 +332,14 @@
     NI_ITERATOR_NEXT(buffer->iterator, buffer->array_data);
     /* implement boundary conditions to the line: */
     if (buffer->size1 + buffer->size2 > 0)
-      if (!NI_ExtendLine(pb - buffer->size1, length, buffer->size1, 
-                         buffer->size2, buffer->extend_mode, 
+      if (!NI_ExtendLine(pb - buffer->size1, length, buffer->size1,
+                         buffer->size2, buffer->extend_mode,
                          buffer->extend_value))
         return 0;
     /* The number of the array lines copied: */
     ++(buffer->next_line);
     /* keep track of (and return) the number of lines in the buffer: */
-    ++(*number_of_lines);  
+    ++(*number_of_lines);
     pb += buffer->line_length + buffer->size1 + buffer->size2;
   }
   /* if not all array lines were processed, *more is set true: */
@@ -405,7 +405,7 @@
 /******************************************************************/
 
 /* Initialize a filter iterator: */
-int 
+int
 NI_InitFilterIterator(int rank, maybelong *filter_shape,
           maybelong filter_size, maybelong *array_shape,
           maybelong *origins, NI_FilterIterator *iterator)
@@ -428,7 +428,7 @@
     }
   }
   for(ii = 0; ii < rank; ii++) {
-    maybelong step = array_shape[ii] < fshape[ii] ? 
+    maybelong step = array_shape[ii] < fshape[ii] ?
                                              array_shape[ii] : fshape[ii];
     maybelong orgn = fshape[ii] / 2 + forigins[ii];
     /* stride for stepping back to previous offsets: */
@@ -452,7 +452,7 @@
   maybelong max_stride = 0, *ashape = NULL, *astrides = NULL;
   maybelong footprint_size = 0, coordinates[MAXDIM], position[MAXDIM];
   maybelong fshape[MAXDIM], forigins[MAXDIM], *po, *pc = NULL;
-  
+
   rank = array->nd;
   ashape = array->dimensions;
   astrides = array->strides;
@@ -466,7 +466,7 @@
   /* calculate the number of non-zero elements in the footprint: */
   if (footprint) {
     for(kk = 0; kk < filter_size; kk++)
-      if (footprint[kk]) 
+      if (footprint[kk])
         ++footprint_size;
   } else {
     footprint_size = filter_size;
@@ -482,7 +482,7 @@
     goto exit;
   }
   if (coordinate_offsets) {
-    *coordinate_offsets = (maybelong*)malloc(offsets_size * rank * 
+    *coordinate_offsets = (maybelong*)malloc(offsets_size * rank *
                                        footprint_size * sizeof(maybelong));
     if (!*coordinate_offsets) {
       PyErr_NoMemory();
@@ -503,10 +503,10 @@
     /* keep track of the kernel position: */
     position[ii] = 0;
   }
-  /* the flag to indicate that we are outside the border must have a 
+  /* the flag to indicate that we are outside the border must have a
      value that is larger than any possible offset: */
   *border_flag_value = max_size * max_stride + 1;
-  /* calculate all possible offsets to elements in the filter kernel, 
+  /* calculate all possible offsets to elements in the filter kernel,
      for all regions in the array (interior and border regions): */
   po = *offsets;
   if (coordinate_offsets) {
@@ -518,7 +518,7 @@
     for(kk = 0; kk < filter_size; kk++) {
       maybelong offset = 0;
       /* only calculate an offset if the footprint is 1: */
-      if (!footprint || footprint[kk]) { 
+      if (!footprint || footprint[kk]) {
         /* find offsets along all axes: */
         for(ii = 0; ii < rank; ii++) {
           maybelong orgn = fshape[ii] / 2 + forigins[ii];
@@ -572,7 +572,7 @@
                 cc = 0;
               } else {
                 int sz = len;
-                cc += sz * (int)(-cc / sz); 
+                cc += sz * (int)(-cc / sz);
                 if (cc < 0)
                   cc += sz;
               }
@@ -581,7 +581,7 @@
                 cc = 0;
               } else {
                 int sz = len;
-                cc -= sz * (int)(cc / sz); 
+                cc -= sz * (int)(cc / sz);
               }
             }
             break;
@@ -633,7 +633,7 @@
         }
       }
     }
-    
+
     /* move to the next array region: */
     for(ii = rank - 1; ii >= 0; ii--) {
       int orgn = fshape[ii] / 2 + forigins[ii];
@@ -651,7 +651,7 @@
       }
     }
   }
-  
+
  exit:
   if (PyErr_Occurred()) {
     if (*offsets)
@@ -678,7 +678,7 @@
   return list;
 }
 
-int NI_CoordinateListStealBlocks(NI_CoordinateList *list1, 
+int NI_CoordinateListStealBlocks(NI_CoordinateList *list1,
                                  NI_CoordinateList *list2)
 {
   if (list1->block_size != list2->block_size ||
@@ -703,7 +703,7 @@
     PyErr_NoMemory();
     goto exit;
   }
-  block->coordinates = (maybelong*)malloc(list->block_size * list->rank * 
+  block->coordinates = (maybelong*)malloc(list->block_size * list->rank *
 					  sizeof(maybelong));
   if (!block->coordinates) {
     PyErr_NoMemory();
@@ -712,7 +712,7 @@
   block->next = list->blocks;
   list->blocks = block;
   block->size = 0;
-  
+
 exit:
   if (PyErr_Occurred()) {
     if (block)
@@ -727,7 +727,7 @@
   NI_CoordinateBlock* block = list->blocks;
   if (block) {
     list->blocks = block->next;
-    if (block->coordinates) 
+    if (block->coordinates)
       free(block->coordinates);
     free(block);
   }

Modified: trunk/Lib/ndimage/src/ni_support.h
===================================================================
--- trunk/Lib/ndimage/src/ni_support.h	2007-03-28 21:54:24 UTC (rev 2885)
+++ trunk/Lib/ndimage/src/ni_support.h	2007-03-29 09:20:23 UTC (rev 2886)
@@ -2,7 +2,7 @@
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
- * are met: 
+ * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
@@ -15,7 +15,7 @@
  * 3. The name of the author may not be used to endorse or promote
  *    products derived from this software without specific prior
  *    written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef NI_SUPPORT_H
@@ -154,7 +154,7 @@
 /******************************************************************/
 
 /* the linebuffer structure: */
-typedef struct { 
+typedef struct {
   double *buffer_data;
   maybelong buffer_lines, line_length, line_stride;
   maybelong size1, size2, array_lines, next_line;
@@ -174,7 +174,7 @@
                           maybelong*, maybelong, double**);
 
 /* Initialize a line buffer */
-int NI_InitLineBuffer(PyArrayObject*, int, maybelong, maybelong, maybelong, 
+int NI_InitLineBuffer(PyArrayObject*, int, maybelong, maybelong, maybelong,
                       double*, NI_ExtendMode, double, NI_LineBuffer*);
 
 /* Extend a line in memory to implement boundary conditions: */



More information about the Scipy-svn mailing list