[Numpy-svn] r2778 - in trunk/numpy: core/include/numpy f2py f2py/src
numpy-svn at scipy.org
numpy-svn at scipy.org
Fri Jul 7 20:49:39 EDT 2006
Author: oliphant
Date: 2006-07-07 19:49:35 -0500 (Fri, 07 Jul 2006)
New Revision: 2778
Modified:
trunk/numpy/core/include/numpy/arrayobject.h
trunk/numpy/f2py/cb_rules.py
trunk/numpy/f2py/cfuncs.py
trunk/numpy/f2py/rules.py
trunk/numpy/f2py/src/fortranobject.c
trunk/numpy/f2py/src/fortranobject.h
Log:
Fix f2py to use new names
Modified: trunk/numpy/core/include/numpy/arrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/arrayobject.h 2006-07-08 00:33:54 UTC (rev 2777)
+++ trunk/numpy/core/include/numpy/arrayobject.h 2006-07-08 00:49:35 UTC (rev 2778)
@@ -36,7 +36,7 @@
#define NPY_SUCCEED 1
/* Helpful to distinguish what is installed */
-#define NDARRAY_VERSION 0x00090907
+#define NDARRAY_VERSION 0x00090908
#define NPY_VERSION NDARRAY_VERSION
/* Some platforms don't define bool, long long, or long double.
Modified: trunk/numpy/f2py/cb_rules.py
===================================================================
--- trunk/numpy/f2py/cb_rules.py 2006-07-08 00:33:54 UTC (rev 2777)
+++ trunk/numpy/f2py/cb_rules.py 2006-07-08 00:49:35 UTC (rev 2778)
@@ -349,7 +349,7 @@
},
# Array ...
{
- 'decl':'\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',
+ 'decl':'\tnpy_intp #varname#_Dims[#rank#] = {#rank*[-1]#};',
'setdims':'\t#cbsetdims#;',
'_check':isarray,
'_depend':''
Modified: trunk/numpy/f2py/cfuncs.py
===================================================================
--- trunk/numpy/f2py/cfuncs.py 2006-07-08 00:33:54 UTC (rev 2777)
+++ trunk/numpy/f2py/cfuncs.py 2006-07-08 00:49:35 UTC (rev 2778)
@@ -294,17 +294,17 @@
case PyArray_FLOAT: *(float *)(arr->data)=*v; break;\\
case PyArray_CDOUBLE: *(double *)(arr->data)=*v; break;\\
case PyArray_CFLOAT: *(float *)(arr->data)=*v; break;\\
- case PyArray_BOOL: *(Bool *)(arr->data)=(*v!=0); break;\\
+ case PyArray_BOOL: *(npy_bool *)(arr->data)=(*v!=0); break;\\
case PyArray_UBYTE: *(unsigned char *)(arr->data)=*v; break;\\
case PyArray_BYTE: *(signed char *)(arr->data)=*v; break;\\
case PyArray_SHORT: *(short *)(arr->data)=*v; break;\\
- case PyArray_USHORT: *(ushort *)(arr->data)=*v; break;\\
- case PyArray_UINT: *(uint *)(arr->data)=*v; break;\\
- case PyArray_ULONG: *(ulong *)(arr->data)=*v; break;\\
- case PyArray_LONGLONG: *(longlong *)(arr->data)=*v; break;\\
- case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=*v; break;\\
- case PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\
- case PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\
+ case PyArray_USHORT: *(npy_ushort *)(arr->data)=*v; break;\\
+ case PyArray_UINT: *(npy_uint *)(arr->data)=*v; break;\\
+ case PyArray_ULONG: *(npy_ulong *)(arr->data)=*v; break;\\
+ case PyArray_LONGLONG: *(npy_longlong *)(arr->data)=*v; break;\\
+ case PyArray_ULONGLONG: *(npy_ulonglong *)(arr->data)=*v; break;\\
+ case PyArray_LONGDOUBLE: *(npy_longdouble *)(arr->data)=*v; break;\\
+ case PyArray_CLONGDOUBLE: *(npy_longdouble *)(arr->data)=*v; break;\\
case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data, arr); break;\\
default: return -2;\\
};\\
@@ -334,17 +334,17 @@
case PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\
case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\
case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\
- case PyArray_BOOL: *(Bool *)(arr->data)=((*v).r!=0 && (*v).i!=0)); break;\\
+ case PyArray_BOOL: *(npy_bool *)(arr->data)=((*v).r!=0 && (*v).i!=0)); break;\\
case PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\
case PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\
case PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\
- case PyArray_USHORT: *(ushort *)(arr->data)=(*v).r; break;\\
- case PyArray_UINT: *(uint *)(arr->data)=(*v).r; break;\\
- case PyArray_ULONG: *(ulong *)(arr->data)=(*v).r; break;\\
- case PyArray_LONGLONG: *(longlong *)(arr->data)=(*v).r; break;\\
- case PyArray_ULONGLONG: *(ulonglong *)(arr->data)=(*v).r; break;\\
- case PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=(*v).r; break;\\
- case PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=(*v).r;*(longdouble *)(arr->data+sizeof(longdouble))=(*v).i;break;\\
+ case PyArray_USHORT: *(npy_ushort *)(arr->data)=(*v).r; break;\\
+ case PyArray_UINT: *(npy_uint *)(arr->data)=(*v).r; break;\\
+ case PyArray_ULONG: *(npy_ulong *)(arr->data)=(*v).r; break;\\
+ case PyArray_LONGLONG: *(npy_longlong *)(arr->data)=(*v).r; break;\\
+ case PyArray_ULONGLONG: *(npy_ulonglong *)(arr->data)=(*v).r; break;\\
+ case PyArray_LONGDOUBLE: *(npy_longdouble *)(arr->data)=(*v).r; break;\\
+ case PyArray_CLONGDOUBLE: *(npy_longdouble *)(arr->data)=(*v).r;*(npy_longdouble *)(arr->data+sizeof(npy_longdouble))=(*v).i;break;\\
case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;\\
default: return -2;\\
};\\
@@ -510,8 +510,8 @@
\treturn ii;
}"""
cfuncs['forcomb']="""\
-static struct { int nd;intp *d;int *i,*i_tr,tr; } forcombcache;
-static int initforcomb(intp *dims,int nd,int tr) {
+static struct { int nd;npy_intp *d;int *i,*i_tr,tr; } forcombcache;
+static int initforcomb(npy_intp *dims,int nd,int tr) {
int k;
if (dims==NULL) return 0;
if (nd<0) return 0;
@@ -757,7 +757,7 @@
\t\t\treturn 1;
\t\t}
\t\telse if (PyArray_Check(obj) && PyArray_TYPE(obj)==PyArray_LONGDOUBLE) {
-\t\t\t(*v) = *((longdouble *)PyArray_DATA(obj))
+\t\t\t(*v) = *((npy_longdouble *)PyArray_DATA(obj))
\t\t\treturn 1;
\t\t}
\t}
@@ -830,8 +830,8 @@
\t\t\treturn 1;
\t\t}
\t\telse if (PyArray_Check(obj) && PyArray_TYPE(obj)==PyArray_CLONGDOUBLE) {
-\t\t\t(*v).r = ((clongdouble *)PyArray_DATA(obj))->real;
-\t\t\t(*v).i = ((clongdouble *)PyArray_DATA(obj))->imag;
+\t\t\t(*v).r = ((npy_clongdouble *)PyArray_DATA(obj))->real;
+\t\t\t(*v).i = ((npy_clongdouble *)PyArray_DATA(obj))->imag;
\t\t\treturn 1;
\t\t}
\t}
@@ -854,13 +854,13 @@
\t}
\tif (PyArray_IsScalar(obj, ComplexFloating)) {
\t\tif (PyArray_IsScalar(obj, CFloat)) {
-\t\t\tcfloat new;
+\t\t\tnpy_cfloat new;
\t\t\tPyArray_ScalarAsCtype(obj, &new);
\t\t\t(*v).r = (double)new.real;
\t\t\t(*v).i = (double)new.imag;
\t\t}
\t\telse if (PyArray_IsScalar(obj, CLongDouble)) {
-\t\t\tclongdouble new;
+\t\t\tnpy_clongdouble new;
\t\t\tPyArray_ScalarAsCtype(obj, &new);
\t\t\t(*v).r = (double)new.real;
\t\t\t(*v).i = (double)new.imag;
@@ -879,8 +879,8 @@
\t\t\tarr = PyArray_FromScalar(obj, PyArray_DescrFromType(PyArray_CDOUBLE));
\t\t}
\t\tif (arr==NULL) return 0;
-\t\t(*v).r = ((cdouble *)PyArray_DATA(arr))->real;
-\t\t(*v).i = ((cdouble *)PyArray_DATA(arr))->imag;
+\t\t(*v).r = ((npy_cdouble *)PyArray_DATA(arr))->real;
+\t\t(*v).i = ((npy_cdouble *)PyArray_DATA(arr))->imag;
\t\treturn 1;
\t}
\t/* Python does not provide PyNumber_Complex function :-( */
Modified: trunk/numpy/f2py/rules.py
===================================================================
--- trunk/numpy/f2py/rules.py 2006-07-08 00:33:54 UTC (rev 2777)
+++ trunk/numpy/f2py/rules.py 2006-07-08 00:49:35 UTC (rev 2778)
@@ -562,7 +562,7 @@
# Array
{ # Common
'decl':['\t#ctype# *#varname# = NULL;',
- '\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',
+ '\tnpy_intp #varname#_Dims[#rank#] = {#rank*[-1]#};',
'\tconst int #varname#_Rank = #rank#;',
],
'need':['len..',{hasinitvalue:'forcomb'},{hasinitvalue:'CFUNCSMESS'}],
@@ -896,7 +896,7 @@
# Array
{ # Common
'decl':['\t#ctype# *#varname# = NULL;',
- '\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',
+ '\tnpy_intp #varname#_Dims[#rank#] = {#rank*[-1]#};',
'\tconst int #varname#_Rank = #rank#;',
'\tPyArrayObject *capi_#varname#_tmp = NULL;',
'\tint capi_#varname#_intent = 0;',
Modified: trunk/numpy/f2py/src/fortranobject.c
===================================================================
--- trunk/numpy/f2py/src/fortranobject.c 2006-07-08 00:33:54 UTC (rev 2777)
+++ trunk/numpy/f2py/src/fortranobject.c 2006-07-08 00:49:35 UTC (rev 2778)
@@ -145,7 +145,7 @@
}
static FortranDataDef *save_def; /* save pointer of an allocatable array */
-static void set_data(char *d,intp *f) { /* callback from Fortran */
+static void set_data(char *d,npy_intp *f) { /* callback from Fortran */
if (*f) /* In fortran f=allocated(d) */
save_def->data = d;
else
@@ -219,7 +219,7 @@
return -1;
}
if (fp->defs[i].func!=NULL) { /* is allocatable array */
- intp dims[F2PY_MAX_DIMS];
+ npy_intp dims[F2PY_MAX_DIMS];
int k;
save_def = &fp->defs[i];
if (v!=Py_None) { /* set new value (reallocate if needed --
@@ -234,13 +234,13 @@
(*(fp->defs[i].func))(&fp->defs[i].rank,dims,set_data,&flag);
for(k=0;k<fp->defs[i].rank;k++) dims[k]=-1;
}
- memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(intp));
+ memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(npy_intp));
} else { /* not allocatable array */
if ((arr = array_from_pyobj(fp->defs[i].type,fp->defs[i].dims.d,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)
return -1;
}
if (fp->defs[i].data!=NULL) { /* copy Python object to Fortran array */
- intp s = PyArray_MultiplyList(fp->defs[i].dims.d,arr->nd);
+ npy_intp s = PyArray_MultiplyList(fp->defs[i].dims.d,arr->nd);
if (s==-1)
s = PyArray_MultiplyList(arr->dimensions,arr->nd);
if (s<0 ||
@@ -448,7 +448,7 @@
static int
count_nonpos(const int rank,
- const intp *dims) {
+ const npy_intp *dims) {
int i=0,r=0;
while (i<rank) {
if (dims[i] <= 0) ++r;
@@ -459,10 +459,10 @@
static int check_and_fix_dimensions(const PyArrayObject* arr,
const int rank,
- intp *dims);
+ npy_intp *dims);
#ifdef DEBUG_COPY_ND_ARRAY
-void dump_dims(int rank, intp* dims) {
+void dump_dims(int rank, npy_intp* dims) {
int i;
printf("[");
for(i=0;i<rank;++i) {
@@ -472,7 +472,7 @@
}
void dump_attrs(const PyArrayObject* arr) {
int rank = arr->nd;
- intp size = PyArray_Size((PyObject *)arr);
+ npy_intp size = PyArray_Size((PyObject *)arr);
printf("\trank = %d, flags = %d, size = %" INTP_FMT "\n",
rank,arr->flags,size);
printf("\tstrides = ");
@@ -487,8 +487,8 @@
static int swap_arrays(PyArrayObject* arr1, PyArrayObject* arr2) {
SWAPTYPE(arr1->data,arr2->data,char*);
SWAPTYPE(arr1->nd,arr2->nd,int);
- SWAPTYPE(arr1->dimensions,arr2->dimensions,intp*);
- SWAPTYPE(arr1->strides,arr2->strides,intp*);
+ SWAPTYPE(arr1->dimensions,arr2->dimensions,npy_intp*);
+ SWAPTYPE(arr1->strides,arr2->strides,npy_intp*);
SWAPTYPE(arr1->base,arr2->base,PyObject*);
SWAPTYPE(arr1->descr,arr2->descr,PyArray_Descr*);
SWAPTYPE(arr1->flags,arr2->flags,int);
@@ -504,7 +504,7 @@
extern
PyArrayObject* array_from_pyobj(const int type_num,
- intp *dims,
+ npy_intp *dims,
const int rank,
const int intent,
PyObject *obj) {
@@ -668,20 +668,20 @@
/*****************************************/
static
-int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,intp *dims) {
+int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,npy_intp *dims) {
/*
This function fills in blanks (that are -1\'s) in dims list using
the dimensions from arr. It also checks that non-blank dims will
match with the corresponding values in arr dimensions.
*/
- const intp arr_size = (arr->nd)?PyArray_Size((PyObject *)arr):1;
+ const npy_intp arr_size = (arr->nd)?PyArray_Size((PyObject *)arr):1;
#ifdef DEBUG_COPY_ND_ARRAY
dump_attrs(arr);
printf("check_and_fix_dimensions:init: dims=");
dump_dims(rank,dims);
#endif
if (rank > arr->nd) { /* [1,2] -> [[1],[2]]; 1 -> [[1]] */
- intp new_size = 1;
+ npy_intp new_size = 1;
int free_axe = -1;
int i;
/* Fill dims where -1 or 0; check dimensions; calc new_size; */
@@ -721,7 +721,7 @@
}
} else if (rank==arr->nd) {
int i;
- intp d;
+ npy_intp d;
for (i=0; i<rank; ++i) {
d = arr->dimensions[i];
if (dims[i]>=0) {
@@ -736,9 +736,9 @@
}
} else { /* [[1,2]] -> [[1],[2]] */
int i,j;
- intp d;
+ npy_intp d;
int effrank;
- intp size;
+ npy_intp size;
for (i=0,effrank=0;i<arr->nd;++i)
if (arr->dimensions[i]>1) ++effrank;
if (dims[rank-1]>=0)
Modified: trunk/numpy/f2py/src/fortranobject.h
===================================================================
--- trunk/numpy/f2py/src/fortranobject.h 2006-07-08 00:33:54 UTC (rev 2777)
+++ trunk/numpy/f2py/src/fortranobject.h 2006-07-08 00:49:35 UTC (rev 2778)
@@ -58,9 +58,9 @@
#define F2PY_MAX_DIMS 40
-typedef void (*f2py_set_data_func)(char*,intp*);
+typedef void (*f2py_set_data_func)(char*,npy_intp*);
typedef void (*f2py_void_func)(void);
-typedef void (*f2py_init_func)(int*,intp*,f2py_set_data_func,int*);
+typedef void (*f2py_init_func)(int*,npy_intp*,f2py_set_data_func,int*);
/*typedef void* (*f2py_c_func)(void*,...);*/
@@ -70,7 +70,7 @@
char *name; /* attribute (array||routine) name */
int rank; /* array rank, 0 for scalar, max is F2PY_MAX_DIMS,
|| rank=-1 for Fortran routine */
- struct {intp d[F2PY_MAX_DIMS];} dims; /* dimensions of the array, || not used */
+ struct {npy_intp d[F2PY_MAX_DIMS];} dims; /* dimensions of the array, || not used */
int type; /* PyArray_<type> || not used */
char *data; /* pointer to array || Fortran routine */
f2py_init_func func; /* initialization function for
@@ -108,7 +108,7 @@
#define F2PY_INTENT_INPLACE 256
extern PyArrayObject* array_from_pyobj(const int type_num,
- intp *dims,
+ npy_intp *dims,
const int rank,
const int intent,
PyObject *obj);
More information about the Numpy-svn
mailing list