Changeset 14097
- Timestamp:
- 12/05/12 09:13:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/wrappers/python/io/FetchPythonData.cpp
r14093 r14097 23 23 24 24 /*return internal value: */ 25 if (PyFloat_Check( (PyArrayObject*)py_float))25 if (PyFloat_Check(py_float)) 26 26 dscalar=PyFloat_AsDouble(py_float); 27 else if (PyInt_Check( (PyArrayObject*)py_float))27 else if (PyInt_Check(py_float)) 28 28 dscalar=(double)PyInt_AsLong(py_float); 29 else if (PyLong_Check( (PyArrayObject*)py_float))29 else if (PyLong_Check(py_float)) 30 30 dscalar=PyLong_AsDouble(py_float); 31 else if (PyBool_Check( (PyArrayObject*)py_float))31 else if (PyBool_Check(py_float)) 32 32 dscalar=(double)PyLong_AsLong(py_float); 33 else if (PyTuple_Check(py_float) && (int)PyTuple_Size(py_float)==1) 34 FetchData(&dscalar,PyTuple_GetItem(py_float,(Py_ssize_t)0)); 35 else if (PyList_Check(py_float) && (int)PyList_Size(py_float)==1) 36 FetchData(&dscalar,PyList_GetItem(py_float,(Py_ssize_t)0)); 33 37 else 34 38 _error_("unrecognized float type in input!"); … … 44 48 45 49 /*return internal value: */ 46 if (PyInt_Check( (PyArrayObject*)py_long))50 if (PyInt_Check(py_long)) 47 51 iscalar=(int)PyInt_AsLong(py_long); 48 else if (PyLong_Check( (PyArrayObject*)py_long))52 else if (PyLong_Check(py_long)) 49 53 iscalar=(int)PyLong_AsLong(py_long); 50 else if (PyFloat_Check( (PyArrayObject*)py_long))54 else if (PyFloat_Check(py_long)) 51 55 iscalar=(int)PyFloat_AsDouble(py_long); 52 else if (PyBool_Check( (PyArrayObject*)py_long))56 else if (PyBool_Check(py_long)) 53 57 iscalar=(int)PyLong_AsLong(py_long); 58 else if (PyTuple_Check(py_long) && (int)PyTuple_Size(py_long)==1) 59 FetchData(&iscalar,PyTuple_GetItem(py_long,(Py_ssize_t)0)); 60 else if (PyList_Check(py_long) && (int)PyList_Size(py_long)==1) 61 FetchData(&iscalar,PyList_GetItem(py_long,(Py_ssize_t)0)); 54 62 else 55 63 _error_("unrecognized long type in input!"); … … 64 72 bool bscalar; 65 73 66 /*check this is indeed a subtype of long type: */ 67 if(!PyBool_Check(py_boolean))_error_("expecting a boolean in input!"); 68 69 /*extract boolean: */ 70 bscalar=(bool)PyLong_AsLong(py_boolean); 71 72 /*simple copy: */ 74 /*return internal value: */ 75 if (PyBool_Check(py_boolean)) 76 bscalar=(bool)PyLong_AsLong(py_boolean); 77 else if (PyInt_Check(py_boolean)) 78 bscalar=(bool)PyInt_AsLong(py_boolean); 79 else if (PyLong_Check(py_boolean)) 80 bscalar=(bool)PyLong_AsLong(py_boolean); 81 else if (PyTuple_Check(py_boolean) && (int)PyTuple_Size(py_boolean)==1) 82 FetchData(&bscalar,PyTuple_GetItem(py_boolean,(Py_ssize_t)0)); 83 else if (PyList_Check(py_boolean) && (int)PyList_Size(py_boolean)==1) 84 FetchData(&bscalar,PyList_GetItem(py_boolean,(Py_ssize_t)0)); 85 else 86 _error_("unrecognized boolean type in input!"); 87 88 /*output: */ 73 89 *pscalar=bscalar; 74 75 90 } 76 91 /*}}}*/ … … 132 147 } 133 148 134 else if (PyFloat_Check((PyArrayObject*)py_matrix) || 135 PyInt_Check((PyArrayObject*)py_matrix) || 136 PyLong_Check((PyArrayObject*)py_matrix) || 137 PyBool_Check((PyArrayObject*)py_matrix)) { 149 else { 138 150 M=1; 139 151 N=1; … … 141 153 FetchData(&(matrix[0]),py_matrix); 142 154 } 143 144 else145 _error_("unrecognized array type in input!");146 155 147 156 /*output: */ … … 208 217 } 209 218 210 else if (PyInt_Check((PyArrayObject*)py_matrix) || 211 PyLong_Check((PyArrayObject*)py_matrix) || 212 PyFloat_Check((PyArrayObject*)py_matrix) || 213 PyBool_Check((PyArrayObject*)py_matrix)) { 219 else { 214 220 M=1; 215 221 N=1; … … 217 223 FetchData(&(matrix[0]),py_matrix); 218 224 } 219 220 else221 _error_("unrecognized array type in input!");222 225 223 226 /*output: */
Note:
See TracChangeset
for help on using the changeset viewer.