From 27b8e54598a325b53fc73b2017ef5e2272f3e5f4 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 8 Mar 2018 13:20:19 -0700 Subject: MAINT: Hard tab and whitespace cleanup. --- numpy/f2py/src/fortranobject.c | 85 +++++++++++----------- numpy/f2py/src/fortranobject.h | 26 +++---- numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c | 26 +++---- numpy/f2py/tests/test_semicolon_split.py | 12 +-- 4 files changed, 75 insertions(+), 74 deletions(-) (limited to 'numpy/f2py') diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index a47733433..dd2484eb4 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -241,7 +241,7 @@ fortran_doc(FortranDataDef def) static FortranDataDef *save_def; /* save pointer of an allocatable array */ static void set_data(char *d,npy_intp *f) { /* callback from Fortran */ - if (*f) /* In fortran f=allocated(d) */ + if (*f) /* In fortran f=allocated(d) */ save_def->data = d; else save_def->data = NULL; @@ -439,23 +439,23 @@ PyTypeObject PyFortran_Type = { PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(0) - 0, /*ob_size*/ + 0, /*ob_size*/ #endif "fortran", /*tp_name*/ sizeof(PyFortranObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ + 0, /*tp_itemsize*/ /* methods */ - (destructor)fortran_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ + (destructor)fortran_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ (getattrfunc)fortran_getattr, /*tp_getattr*/ (setattrfunc)fortran_setattr, /*tp_setattr*/ - 0, /*tp_compare/tp_reserved*/ - (reprfunc)fortran_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - (ternaryfunc)fortran_call, /*tp_call*/ + 0, /*tp_compare/tp_reserved*/ + (reprfunc)fortran_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + (ternaryfunc)fortran_call, /*tp_call*/ }; /************************* f2py_report_atexit *******************************/ @@ -656,17 +656,18 @@ PyArrayObject* array_from_pyobj(const int type_num, const int rank, const int intent, PyObject *obj) { - /* Note about reference counting - ----------------------------- - If the caller returns the array to Python, it must be done with - Py_BuildValue("N",arr). - Otherwise, if obj!=arr then the caller must call Py_DECREF(arr). - - Note on intent(cache,out,..) - --------------------- - Don't expect correct data when returning intent(cache) array. - - */ + /* + * Note about reference counting + * ----------------------------- + * If the caller returns the array to Python, it must be done with + * Py_BuildValue("N",arr). + * Otherwise, if obj!=arr then the caller must call Py_DECREF(arr). + * + * Note on intent(cache,out,..) + * --------------------- + * Don't expect correct data when returning intent(cache) array. + * + */ char mess[200]; PyArrayObject *arr = NULL; PyArray_Descr *descr; @@ -744,17 +745,17 @@ PyArrayObject* array_from_pyobj(const int type_num, if (check_and_fix_dimensions(arr, rank, dims)) { return NULL; } - /* - printf("intent alignment=%d\n", F2PY_GET_ALIGNMENT(intent)); - printf("alignment check=%d\n", F2PY_CHECK_ALIGNMENT(arr, intent)); - int i; - for (i=1;i<=16;i++) - printf("i=%d isaligned=%d\n", i, ARRAY_ISALIGNED(arr, i)); - */ + /* + printf("intent alignment=%d\n", F2PY_GET_ALIGNMENT(intent)); + printf("alignment check=%d\n", F2PY_CHECK_ALIGNMENT(arr, intent)); + int i; + for (i=1;i<=16;i++) + printf("i=%d isaligned=%d\n", i, ARRAY_ISALIGNED(arr, i)); + */ if ((! (intent & F2PY_INTENT_COPY)) && PyArray_ITEMSIZE(arr)==elsize && ARRAY_ISCOMPATIBLE(arr,type_num) - && F2PY_CHECK_ALIGNMENT(arr, intent) + && F2PY_CHECK_ALIGNMENT(arr, intent) ) { if ((intent & F2PY_INTENT_C)?PyArray_ISCARRAY(arr):PyArray_ISFARRAY(arr)) { if ((intent & F2PY_INTENT_OUT)) { @@ -780,8 +781,8 @@ PyArrayObject* array_from_pyobj(const int type_num, if (!(ARRAY_ISCOMPATIBLE(arr,type_num))) sprintf(mess+strlen(mess)," -- input '%c' not compatible to '%c'", PyArray_DESCR(arr)->type,typechar); - if (!(F2PY_CHECK_ALIGNMENT(arr, intent))) - sprintf(mess+strlen(mess)," -- input not %d-aligned", F2PY_GET_ALIGNMENT(intent)); + if (!(F2PY_CHECK_ALIGNMENT(arr, intent))) + sprintf(mess+strlen(mess)," -- input not %d-aligned", F2PY_GET_ALIGNMENT(intent)); PyErr_SetString(PyExc_ValueError,mess); return NULL; } @@ -858,14 +859,14 @@ static 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. - - Returns 0 if the function is successful. - - If an error condition is detected, an exception is set and 1 is returned. - */ + * 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. + * + * Returns 0 if the function is successful. + * + * If an error condition is detected, an exception is set and 1 is returned. + */ const npy_intp arr_size = (PyArray_NDIM(arr))?PyArray_Size((PyObject *)arr):1; #ifdef DEBUG_COPY_ND_ARRAY dump_attrs(arr); @@ -922,7 +923,7 @@ int check_and_fix_dimensions(const PyArrayObject* arr, const int rank, npy_intp int i; npy_intp d; for (i=0; i=0) { if (d > 1 && d!=dims[i]) { PyErr_Format(PyExc_ValueError, diff --git a/numpy/f2py/src/fortranobject.h b/numpy/f2py/src/fortranobject.h index c9b54e259..5d0dcf676 100644 --- a/numpy/f2py/src/fortranobject.h +++ b/numpy/f2py/src/fortranobject.h @@ -78,16 +78,16 @@ typedef void *(*f2pycfunc)(void); typedef struct { char *name; /* attribute (array||routine) name */ int rank; /* array rank, 0 for scalar, max is F2PY_MAX_DIMS, - || rank=-1 for Fortran routine */ + || rank=-1 for Fortran routine */ struct {npy_intp d[F2PY_MAX_DIMS];} dims; /* dimensions of the array, || not used */ int type; /* PyArray_ || not used */ char *data; /* pointer to array || Fortran routine */ - f2py_init_func func; /* initialization function for - allocatable arrays: - func(&rank,dims,set_ptr_func,name,len(name)) - || C/API wrapper for Fortran routine */ + f2py_init_func func; /* initialization function for + allocatable arrays: + func(&rank,dims,set_ptr_func,name,len(name)) + || C/API wrapper for Fortran routine */ char *doc; /* documentation string; only recommended - for routines. */ + for routines. */ } FortranDataDef; typedef struct { @@ -139,16 +139,16 @@ int F2PyCapsule_Check(PyObject *ptr); #define F2PY_ALIGN16(intent) (intent & F2PY_INTENT_ALIGNED16) #define F2PY_GET_ALIGNMENT(intent) \ - (F2PY_ALIGN4(intent) ? 4 : \ - (F2PY_ALIGN8(intent) ? 8 : \ - (F2PY_ALIGN16(intent) ? 16 : 1) )) + (F2PY_ALIGN4(intent) ? 4 : \ + (F2PY_ALIGN8(intent) ? 8 : \ + (F2PY_ALIGN16(intent) ? 16 : 1) )) #define F2PY_CHECK_ALIGNMENT(arr, intent) ARRAY_ISALIGNED(arr, F2PY_GET_ALIGNMENT(intent)) extern PyArrayObject* array_from_pyobj(const int type_num, - npy_intp *dims, - const int rank, - const int intent, - PyObject *obj); + npy_intp *dims, + const int rank, + const int intent, + PyObject *obj); extern int copy_ND_array(const PyArrayObject *in, PyArrayObject *out); #ifdef DEBUG_COPY_ND_ARRAY diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c index 22801abdc..7f46303b0 100644 --- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c @@ -33,7 +33,7 @@ Required arguments:\n" "Return objects:\n" " arr : array"; static PyObject *f2py_rout_wrap_call(PyObject *capi_self, - PyObject *capi_args) { + PyObject *capi_args) { PyObject * volatile capi_buildvalue = NULL; int type_num = 0; npy_intp *dims = NULL; @@ -45,7 +45,7 @@ static PyObject *f2py_rout_wrap_call(PyObject *capi_self, int i; if (!PyArg_ParseTuple(capi_args,"iOiO|:wrap.call",\ - &type_num,&dims_capi,&intent,&arr_capi)) + &type_num,&dims_capi,&intent,&arr_capi)) return NULL; rank = PySequence_Length(dims_capi); dims = malloc(rank*sizeof(npy_intp)); @@ -78,7 +78,7 @@ Required arguments:\n" " itemsize : int\n" ; static PyObject *f2py_rout_wrap_attrs(PyObject *capi_self, - PyObject *capi_args) { + PyObject *capi_args) { PyObject *arr_capi = Py_None; PyArrayObject *arr = NULL; PyObject *dimensions = NULL; @@ -87,7 +87,7 @@ static PyObject *f2py_rout_wrap_attrs(PyObject *capi_self, int i; memset(s,0,100*sizeof(char)); if (!PyArg_ParseTuple(capi_args,"O!|:wrap.attrs", - &PyArray_Type,&arr_capi)) + &PyArray_Type,&arr_capi)) return NULL; arr = (PyArrayObject *)arr_capi; sprintf(s,"%p",PyArray_DATA(arr)); @@ -98,15 +98,15 @@ static PyObject *f2py_rout_wrap_attrs(PyObject *capi_self, PyTuple_SetItem(strides,i,PyInt_FromLong(PyArray_STRIDE(arr,i))); } return Py_BuildValue("siOOO(cciii)ii",s,PyArray_NDIM(arr), - dimensions,strides, - (PyArray_BASE(arr)==NULL?Py_None:PyArray_BASE(arr)), - PyArray_DESCR(arr)->kind, - PyArray_DESCR(arr)->type, - PyArray_TYPE(arr), - PyArray_ITEMSIZE(arr), - PyArray_DESCR(arr)->alignment, - PyArray_FLAGS(arr), - PyArray_ITEMSIZE(arr)); + dimensions,strides, + (PyArray_BASE(arr)==NULL?Py_None:PyArray_BASE(arr)), + PyArray_DESCR(arr)->kind, + PyArray_DESCR(arr)->type, + PyArray_TYPE(arr), + PyArray_ITEMSIZE(arr), + PyArray_DESCR(arr)->alignment, + PyArray_FLAGS(arr), + PyArray_ITEMSIZE(arr)); } static PyMethodDef f2py_module_methods[] = { diff --git a/numpy/f2py/tests/test_semicolon_split.py b/numpy/f2py/tests/test_semicolon_split.py index d844e2eae..2b0f32727 100644 --- a/numpy/f2py/tests/test_semicolon_split.py +++ b/numpy/f2py/tests/test_semicolon_split.py @@ -9,14 +9,14 @@ class TestMultiline(util.F2PyTest): code = """ python module {module} usercode ''' -void foo(int* x) {{ +void foo(int* x) {{ char dummy = ';'; - *x = 42; + *x = 42; }} ''' interface subroutine foo(x) - intent(c) foo + intent(c) foo integer intent(out) :: x end subroutine foo end interface @@ -37,11 +37,11 @@ void foo(int* x) {{ ''' interface subroutine foo(x) - intent(c) foo + intent(c) foo integer intent(out) :: x - callprotoargument int* + callprotoargument int* callstatement {{ & - ; & + ; & x = 42; & }} end subroutine foo -- cgit v1.2.1