[Scipy-svn] r2879 - in trunk/Lib/ndimage: . src

scipy-svn at scipy.org scipy-svn at scipy.org
Wed Mar 28 10:46:18 EDT 2007


Author: stefan
Date: 2007-03-28 09:46:04 -0500 (Wed, 28 Mar 2007)
New Revision: 2879

Modified:
   trunk/Lib/ndimage/setup.py
   trunk/Lib/ndimage/src/nd_image.h
   trunk/Lib/ndimage/src/ni_interpolation.c
Log:
Port ndimage to numpy API.


Modified: trunk/Lib/ndimage/setup.py
===================================================================
--- trunk/Lib/ndimage/setup.py	2007-03-27 19:23:23 UTC (rev 2878)
+++ trunk/Lib/ndimage/setup.py	2007-03-28 14:46:04 UTC (rev 2879)
@@ -1,6 +1,6 @@
 from numpy.distutils.core import setup
 from numpy.distutils.misc_util import Configuration
-from numpy.numarray import get_numarray_include_dirs
+from numpy import get_include
 
 def configuration(parent_package='', top_path=None):
 
@@ -11,7 +11,7 @@
                  "src/ni_fourier.c","src/ni_interpolation.c",
                  "src/ni_measure.c",
                  "src/ni_morphology.c","src/ni_support.c"],
-        include_dirs=['src']+get_numarray_include_dirs(),
+        include_dirs=['src']+[get_include()],
     )
     
     config.add_data_dir('tests')

Modified: trunk/Lib/ndimage/src/nd_image.h
===================================================================
--- trunk/Lib/ndimage/src/nd_image.h	2007-03-27 19:23:23 UTC (rev 2878)
+++ trunk/Lib/ndimage/src/nd_image.h	2007-03-28 14:46:04 UTC (rev 2879)
@@ -32,20 +32,46 @@
 #ifndef ND_IMAGE_H
 #define ND_IMAGE_H
 
-#if !defined(ND_IMPORT_ARRAY)
-#define NO_IMPORT_ARRAY
-#endif
 #include "Python.h"
-#include "numpy/libnumarray.h"
+#include <numpy/noprefix.h>
 
 #define NI_MAXDIM NPY_MAXDIMS
 
-int NI_GetArrayRank(PyArrayObject*);
+typedef npy_intp maybelong;
+#define MAXDIM NPY_MAXDIMS
+
+typedef enum
+{ 
+     tAny=-1,
+     tBool=PyArray_BOOL,
+     tInt8=PyArray_INT8,
+     tUInt8=PyArray_UINT8,
+     tInt16=PyArray_INT16,
+     tUInt16=PyArray_UINT16,
+     tInt32=PyArray_INT32,
+     tUInt32=PyArray_UINT32,
+     tInt64=PyArray_INT64,
+     tUInt64=PyArray_UINT64,
+     tFloat32=PyArray_FLOAT32,
+     tFloat64=PyArray_FLOAT64,
+     tComplex32=PyArray_COMPLEX64,
+     tComplex64=PyArray_COMPLEX128,
+     tObject=PyArray_OBJECT,        /* placeholder... does nothing */
+     tMaxType=PyArray_NTYPES,
+     tDefault = tFloat64,
+#if NPY_BITSOF_LONG == 64
+     tLong = tInt64,
+#else
+     tLong = tInt32,
+#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*);
+int NI_CheckArray(PyArrayObject*, NumarrayType, int, int*); */
 
 #endif

Modified: trunk/Lib/ndimage/src/ni_interpolation.c
===================================================================
--- trunk/Lib/ndimage/src/ni_interpolation.c	2007-03-27 19:23:23 UTC (rev 2878)
+++ trunk/Lib/ndimage/src/ni_interpolation.c	2007-03-28 14:46:04 UTC (rev 2879)
@@ -308,7 +308,7 @@
 }
  
 #define CASE_MAP_COORDINATES(_p, _coor, _rank, _stride, _type) \
-case t ## _type:                                               \
+case t ## _type:                                                    \
 {                                                              \
   int _hh;                                                     \
   for(_hh = 0; _hh < _rank; _hh++) {                           \
@@ -354,8 +354,8 @@
   double **splvals = NULL, icoor[MAXDIM];
   double idimensions[MAXDIM], istrides[MAXDIM];
   NI_Iterator io, ic;
-  Float64 *matrix = matrix_ar ? (Float64*)NA_OFFSETDATA(matrix_ar) : NULL;
-  Float64 *shift = shift_ar ? (Float64*)NA_OFFSETDATA(shift_ar) : NULL;
+  Float64 *matrix = matrix_ar ? (Float64*)PyArray_DATA(matrix_ar) : NULL;
+  Float64 *shift = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL;
   int irank = 0, orank, qq;
 
   for(kk = 0; kk < input->nd; kk++) {
@@ -373,7 +373,7 @@
     cstride = ic.strides[0];
     if (!NI_LineIterator(&ic, 0))
       goto exit;
-    pc = NA_OFFSETDATA(coordinates);   
+    pc = (void *)(PyArray_DATA(coordinates));
   }
 
   /* offsets used at the borders: */
@@ -422,8 +422,8 @@
     goto exit;
 
   /* get data pointers: */
-  pi = NA_OFFSETDATA(input);
-  po = NA_OFFSETDATA(output);
+  pi = (void *)PyArray_DATA(input);
+  po = (void *)PyArray_DATA(output);
 
   /* make a table of all possible coordinates within the spline filter: */
   fcoordinates = (maybelong*)malloc(irank * filter_size * sizeof(maybelong));
@@ -659,8 +659,8 @@
   maybelong size;
   double ***splvals = NULL;
   NI_Iterator io;
-  Float64 *zooms = zoom_ar ? (Float64*)NA_OFFSETDATA(zoom_ar) : NULL;
-  Float64 *shifts = shift_ar ? (Float64*)NA_OFFSETDATA(shift_ar) : NULL;
+  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++) {
@@ -792,8 +792,8 @@
   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);
     
   /* store all coordinates and offsets with filter: */
   fcoordinates = (maybelong*)malloc(rank * filter_size * sizeof(maybelong));




More information about the Scipy-svn mailing list