From numpy-svn at scipy.org Thu Jun 29 18:59:11 2006 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 29 Jun 2006 17:59:11 -0500 (CDT) Subject: [Numpy-svn] r2706 - trunk/numpy/random/mtrand Message-ID: <20060629225911.03851D40AC2@new.scipy.org> Author: oliphant Date: 2006-06-29 17:59:09 -0500 (Thu, 29 Jun 2006) New Revision: 2706 Modified: trunk/numpy/random/mtrand/mtrand.c Log: Fix up mtrand compile again. Modified: trunk/numpy/random/mtrand/mtrand.c =================================================================== --- trunk/numpy/random/mtrand/mtrand.c 2006-06-29 09:38:32 UTC (rev 2705) +++ trunk/numpy/random/mtrand/mtrand.c 2006-06-29 22:59:09 UTC (rev 2706) @@ -1,16 +1,10 @@ -/* Generated by Pyrex 0.9.4.1 on Mon Jun 12 14:22:41 2006 */ +/* Generated by Pyrex 0.9.3.1 on Thu Jun 29 03:46:57 2006 */ #include "Python.h" #include "structmember.h" #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif -#ifdef __cplusplus -#define __PYX_EXTERN_C extern "C" -#else -#define __PYX_EXTERN_C extern -#endif -__PYX_EXTERN_C double pow(double, double); #include "string.h" #include "math.h" #include "numpy/arrayobject.h" @@ -37,10 +31,11 @@ static PyObject *__pyx_b; static int __pyx_lineno; static char *__pyx_filename; -static char **__pyx_f; +staticforward char **__pyx_f; /* Declarations from mtrand */ +staticforward PyTypeObject __pyx_type_6mtrand_RandomState; struct __pyx_obj_6mtrand_RandomState { PyObject_HEAD @@ -184,7 +179,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":128 */ __pyx_1 = __pyx_v_size == Py_None; @@ -214,7 +209,7 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(((PyObject *)__pyx_4)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; @@ -230,9 +225,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":135 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":136 */ Py_INCREF(((PyObject *)arrayObject)); @@ -241,7 +234,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -266,7 +259,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":144 */ __pyx_1 = __pyx_v_size == Py_None; @@ -296,7 +289,7 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(((PyObject *)__pyx_4)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; @@ -312,9 +305,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":151 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":152 */ Py_INCREF(((PyObject *)arrayObject)); @@ -323,7 +314,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -348,7 +339,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":161 */ __pyx_1 = __pyx_v_size == Py_None; @@ -378,7 +369,7 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(((PyObject *)__pyx_4)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; @@ -394,9 +385,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":168 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":169 */ Py_INCREF(((PyObject *)arrayObject)); @@ -405,7 +394,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -430,7 +419,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":179 */ __pyx_1 = __pyx_v_size == Py_None; @@ -460,7 +449,7 @@ __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(((PyObject *)__pyx_4)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; @@ -476,9 +465,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":186 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":187 */ Py_INCREF(((PyObject *)arrayObject)); @@ -487,7 +474,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -514,7 +501,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":195 */ __pyx_1 = __pyx_v_size == Py_None; @@ -542,7 +529,7 @@ __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(((PyObject *)__pyx_2)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; @@ -558,9 +545,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":202 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":203 */ Py_INCREF(((PyObject *)arrayObject)); @@ -569,7 +554,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -594,7 +579,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":211 */ __pyx_1 = __pyx_v_size == Py_None; @@ -622,7 +607,7 @@ __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(((PyObject *)__pyx_2)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; @@ -638,9 +623,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":218 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":219 */ Py_INCREF(((PyObject *)arrayObject)); @@ -649,7 +632,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -674,7 +657,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":228 */ __pyx_1 = __pyx_v_size == Py_None; @@ -702,7 +685,7 @@ __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(((PyObject *)__pyx_2)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; @@ -718,9 +701,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":235 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":236 */ Py_INCREF(((PyObject *)arrayObject)); @@ -729,7 +710,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -754,7 +735,7 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":244 */ __pyx_1 = __pyx_v_size == Py_None; @@ -782,7 +763,7 @@ __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_INCREF(((PyObject *)__pyx_2)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; @@ -798,9 +779,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":251 */ (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a); - __pyx_L3:; } - __pyx_L4:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":252 */ Py_INCREF(((PyObject *)arrayObject)); @@ -809,7 +788,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -851,9 +830,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":263 */ __pyx_v_sum = __pyx_v_t; - __pyx_L2:; } - __pyx_L3:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":264 */ __pyx_r = __pyx_v_sum; @@ -861,7 +838,6 @@ __pyx_r = 0; goto __pyx_L0; - __pyx_L1:; __Pyx_WriteUnraisable("mtrand.kahan_sum"); __pyx_L0:; return __pyx_r; @@ -926,7 +902,6 @@ __pyx_L2:; goto __pyx_L0; - __pyx_L1:; __Pyx_AddTraceback("mtrand.RandomState.__dealloc__"); __pyx_L0:; Py_DECREF(__pyx_v_self); @@ -951,7 +926,7 @@ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_seed)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_seed); - arrayObject_obj = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject_obj = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_obj); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":308 */ __pyx_1 = __pyx_v_seed == Py_None; @@ -975,7 +950,7 @@ if (__pyx_1) { /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":311 */ - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} rk_seed(__pyx_5,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state); goto __pyx_L2; } @@ -983,7 +958,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":313 */ __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(((PyObject *)__pyx_3)); Py_DECREF(((PyObject *)arrayObject_obj)); arrayObject_obj = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; @@ -993,7 +968,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -1023,7 +998,7 @@ static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - arrayObject_state = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject_state = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_state); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":323 */ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;} @@ -1039,7 +1014,7 @@ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_INCREF(((PyObject *)__pyx_1)); Py_DECREF(((PyObject *)arrayObject_state)); arrayObject_state = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; @@ -1060,7 +1035,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1100,9 +1075,9 @@ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_state)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_state); - arrayObject_obj = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_algorithm_name = Py_None; Py_INCREF(Py_None); - __pyx_v_key = Py_None; Py_INCREF(Py_None); + arrayObject_obj = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_obj); + __pyx_v_algorithm_name = Py_None; Py_INCREF(__pyx_v_algorithm_name); + __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":336 */ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;} @@ -1147,7 +1122,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":340 */ __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_INCREF(((PyObject *)__pyx_4)); Py_DECREF(((PyObject *)arrayObject_obj)); arrayObject_obj = ((PyArrayObject *)__pyx_4); Py_DECREF(__pyx_4); __pyx_4 = 0; @@ -1177,7 +1152,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":344 */ ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1214,7 +1189,7 @@ __pyx_3 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1249,7 +1224,7 @@ Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1301,7 +1276,7 @@ __pyx_3 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1334,7 +1309,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1364,7 +1339,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1407,7 +1382,7 @@ Py_INCREF(__pyx_v_low); Py_INCREF(__pyx_v_high); Py_INCREF(__pyx_v_size); - arrayObject = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":384 */ __pyx_1 = __pyx_v_high == Py_None; @@ -1481,7 +1456,7 @@ __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_INCREF(((PyObject *)__pyx_3)); Py_DECREF(((PyObject *)arrayObject)); arrayObject = ((PyArrayObject *)__pyx_3); Py_DECREF(__pyx_3); __pyx_3 = 0; @@ -1497,9 +1472,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":402 */ (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + ((long )rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state))); - __pyx_L5:; } - __pyx_L6:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":403 */ Py_INCREF(((PyObject *)arrayObject)); @@ -1508,7 +1481,7 @@ } __pyx_L4:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_3); @@ -1534,9 +1507,9 @@ PyObject *__pyx_r; PyObject *__pyx_1 = 0; static char *__pyx_argnames[] = {"length",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "I", __pyx_argnames, &__pyx_v_length)) return 0; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_length)) return 0; Py_INCREF(__pyx_v_self); - __pyx_v_bytestring = Py_None; Py_INCREF(Py_None); + __pyx_v_bytestring = Py_None; Py_INCREF(__pyx_v_bytestring); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":411 */ __pyx_v_bytes = PyMem_Malloc(__pyx_v_length); @@ -1558,7 +1531,7 @@ __pyx_r = __pyx_v_bytestring; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1592,7 +1565,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1671,7 +1644,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1749,7 +1722,7 @@ } __pyx_L2:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1822,7 +1795,7 @@ __pyx_4 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -1856,7 +1829,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1916,7 +1889,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -1994,7 +1967,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2054,7 +2027,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2086,7 +2059,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -2143,7 +2116,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2222,7 +2195,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2300,7 +2273,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2397,7 +2370,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2456,7 +2429,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2534,7 +2507,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2566,7 +2539,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -2623,7 +2596,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2683,7 +2656,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2742,7 +2715,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2801,7 +2774,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2860,7 +2833,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2922,7 +2895,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -2984,7 +2957,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3046,7 +3019,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3108,7 +3081,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3168,7 +3141,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3246,7 +3219,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3343,7 +3316,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3439,7 +3412,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3535,7 +3508,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3595,7 +3568,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3654,7 +3627,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3731,7 +3704,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3846,7 +3819,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3923,7 +3896,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -3986,13 +3959,13 @@ Py_INCREF(__pyx_v_mean); Py_INCREF(__pyx_v_cov); Py_INCREF(__pyx_v_size); - __pyx_v_shape = Py_None; Py_INCREF(Py_None); - __pyx_v_final_shape = Py_None; Py_INCREF(Py_None); - __pyx_v_x = Py_None; Py_INCREF(Py_None); - __pyx_v_svd = Py_None; Py_INCREF(Py_None); - __pyx_v_u = Py_None; Py_INCREF(Py_None); - __pyx_v_s = Py_None; Py_INCREF(Py_None); - __pyx_v_v = Py_None; Py_INCREF(Py_None); + __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape); + __pyx_v_final_shape = Py_None; Py_INCREF(__pyx_v_final_shape); + __pyx_v_x = Py_None; Py_INCREF(__pyx_v_x); + __pyx_v_svd = Py_None; Py_INCREF(__pyx_v_svd); + __pyx_v_u = Py_None; Py_INCREF(__pyx_v_u); + __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s); + __pyx_v_v = Py_None; Py_INCREF(__pyx_v_v); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":816 */ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} @@ -4360,7 +4333,7 @@ __pyx_r = __pyx_v_x; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -4419,10 +4392,10 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_pvals); Py_INCREF(__pyx_v_size); - arrayObject_parr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - arrayObject_mnarr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_shape = Py_None; Py_INCREF(Py_None); - __pyx_v_multin = Py_None; Py_INCREF(Py_None); + arrayObject_parr = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_parr); + arrayObject_mnarr = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_mnarr); + __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape); + __pyx_v_multin = Py_None; Py_INCREF(__pyx_v_multin); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":872 */ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;} @@ -4438,7 +4411,7 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":873 */ __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_INCREF(((PyObject *)__pyx_1)); Py_DECREF(((PyObject *)arrayObject_parr)); arrayObject_parr = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; @@ -4537,7 +4510,7 @@ __pyx_3 = 0; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":887 */ - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_multin))); + Py_INCREF(((PyObject *)__pyx_v_multin)); Py_DECREF(((PyObject *)arrayObject_mnarr)); arrayObject_mnarr = ((PyArrayObject *)__pyx_v_multin); @@ -4549,7 +4522,6 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":890 */ while (1) { - __pyx_L4:; __pyx_5 = (__pyx_v_i < PyArray_SIZE(arrayObject_mnarr)); if (!__pyx_5) break; @@ -4581,7 +4553,6 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":898 */ __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j])); - __pyx_L6:; } __pyx_L7:; @@ -4598,14 +4569,13 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":902 */ __pyx_v_i = (__pyx_v_i + __pyx_v_d); } - __pyx_L5:; /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":904 */ Py_INCREF(__pyx_v_multin); __pyx_r = __pyx_v_multin; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -4659,7 +4629,6 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":916 */ while (1) { - __pyx_L2:; __pyx_5 = (__pyx_v_i > 0); if (!__pyx_5) break; @@ -4685,9 +4654,8 @@ /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":919 */ __pyx_v_i = (__pyx_v_i - 1); } - __pyx_L3:; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -4717,7 +4685,7 @@ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_x)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_x); - __pyx_v_arr = Py_None; Py_INCREF(Py_None); + __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr); /* "/home/oliphant/numpy/numpy/random/mtrand/mtrand.pyx":927 */ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;} @@ -4781,7 +4749,7 @@ __pyx_r = __pyx_v_arr; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -4937,7 +4905,6 @@ } static void __pyx_tp_dealloc_6mtrand_RandomState(PyObject *o) { - struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); @@ -4951,13 +4918,10 @@ } static int __pyx_tp_traverse_6mtrand_RandomState(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o; return 0; } static int __pyx_tp_clear_6mtrand_RandomState(PyObject *o) { - struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o; return 0; } @@ -5081,7 +5045,7 @@ 0, /*bf_getcharbuffer*/ }; -PyTypeObject __pyx_type_6mtrand_RandomState = { +statichere PyTypeObject __pyx_type_6mtrand_RandomState = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "mtrand.RandomState", /*tp_name*/ @@ -5102,7 +5066,7 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_RandomState, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ "Container for the Mersenne Twister PRNG.\n\n Constructor\n -----------\n RandomState(seed=None): initializes the PRNG with the given seed. See the\n seed() method for details.\n\n Distribution Methods\n -----------------\n RandomState exposes a number of methods for generating random numbers drawn\n from a variety of probability distributions. In addition to the\n distribution-specific arguments, each method takes a keyword argument\n size=None. If size is None, then a single value is generated and returned.\n If size is an integer, then a 1-D numpy array filled with generated values\n is returned. If size is a tuple, then a numpy array with that shape is\n filled and returned.\n ", /*tp_doc*/ __pyx_tp_traverse_6mtrand_RandomState, /*tp_traverse*/ __pyx_tp_clear_6mtrand_RandomState, /*tp_clear*/ @@ -5134,13 +5098,10 @@ {0, 0, 0, 0} }; -static void __pyx_init_filenames(void); /*proto*/ - -PyMODINIT_FUNC initmtrand(void); /*proto*/ -PyMODINIT_FUNC initmtrand(void) { +DL_EXPORT(void) initmtrand(void); /*proto*/ +DL_EXPORT(void) initmtrand(void) { PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; - __pyx_init_filenames(); __pyx_m = Py_InitModule4("mtrand", __pyx_methods, 0, 0, PYTHON_API_VERSION); if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}; __pyx_b = PyImport_AddModule("__builtin__"); @@ -5674,13 +5635,10 @@ "mtrand.pyx", "numpy.pxi", }; +statichere char **__pyx_f = __pyx_filenames; /* Runtime support code */ -static void __pyx_init_filenames(void) { - __pyx_f = __pyx_filenames; -} - static int __Pyx_GetStarArgs( PyObject **args, PyObject **kwds, @@ -5745,10 +5703,8 @@ bad: Py_XDECREF(args1); Py_XDECREF(kwds1); - if (*args2) - Py_XDECREF(*args2); - if (*kwds2) - Py_XDECREF(*kwds2); + Py_XDECREF(*args2); + Py_XDECREF(*kwds2); return -1; } @@ -5871,23 +5827,23 @@ } static PyObject *__Pyx_UnpackItem(PyObject *seq, int i) { - PyObject *item; - if (!(item = PySequence_GetItem(seq, i))) { + PyObject *item = PySequence_GetItem(seq, i); + if (!item) { if (PyErr_ExceptionMatches(PyExc_IndexError)) - __Pyx_UnpackError(); + __Pyx_UnpackError(); } return item; } static int __Pyx_EndUnpack(PyObject *seq, int i) { - PyObject *item; - if (item = PySequence_GetItem(seq, i)) { + PyObject *item = PySequence_GetItem(seq, i); + if (item) { Py_DECREF(item); __Pyx_UnpackError(); return -1; } PyErr_Clear(); - return 0; + return 0; } static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { From numpy-svn at scipy.org Thu Jun 29 20:27:38 2006 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Thu, 29 Jun 2006 19:27:38 -0500 (CDT) Subject: [Numpy-svn] r2707 - trunk/numpy/distutils Message-ID: <20060630002738.6284BD40AC2@new.scipy.org> Author: oliphant Date: 2006-06-29 19:27:30 -0500 (Thu, 29 Jun 2006) New Revision: 2707 Modified: trunk/numpy/distutils/system_info.py Log: Fixed lapack finding on intel-mac Modified: trunk/numpy/distutils/system_info.py =================================================================== --- trunk/numpy/distutils/system_info.py 2006-06-29 22:59:09 UTC (rev 2706) +++ trunk/numpy/distutils/system_info.py 2006-06-30 00:27:30 UTC (rev 2707) @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/bin/env python """ This file defines a set of system_info classes for getting information about various resources (libraries, library directories, @@ -1098,6 +1098,7 @@ log.info('Output: %s', o) return atlas_version +from distutils.util import get_platform class lapack_opt_info(system_info): @@ -1106,11 +1107,21 @@ if sys.platform=='darwin' and not os.environ.get('ATLAS',None): args = [] link_args = [] + if get_platform()[-4:] == 'i386': + intel = 1 + else: + intel = 0 if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'): - args.extend(['-faltivec']) + if intel: + args.extend(['-msse3']) + else: + args.extend(['-faltivec']) link_args.extend(['-Wl,-framework','-Wl,Accelerate']) elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'): - args.extend(['-faltivec']) + if intel: + args.extend(['-msse3']) + else: + args.extend(['-faltivec']) link_args.extend(['-Wl,-framework','-Wl,vecLib']) if args: self.set_info(extra_compile_args=args, @@ -1191,15 +1202,25 @@ if sys.platform=='darwin' and not os.environ.get('ATLAS',None): args = [] link_args = [] + if get_platform()[-4:] == 'i386': + intel = 1 + else: + intel = 0 if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'): - args.extend(['-faltivec', - '-I/System/Library/Frameworks/vecLib.framework/Headers', - ]) + if intel: + args.extend(['-msse3']) + else: + args.extend(['-faltivec']) + args.extend([ + '-I/System/Library/Frameworks/vecLib.framework/Headers']) link_args.extend(['-Wl,-framework','-Wl,Accelerate']) elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'): - args.extend(['-faltivec', - '-I/System/Library/Frameworks/vecLib.framework/Headers', - ]) + if intel: + args.extend(['-msse3']) + else: + args.extend(['-faltivec']) + args.extend([ + '-I/System/Library/Frameworks/vecLib.framework/Headers']) link_args.extend(['-Wl,-framework','-Wl,vecLib']) if args: self.set_info(extra_compile_args=args, @@ -1818,7 +1839,8 @@ n = n + '_info' show_only.append(n) show_all = not show_only - for name, c in globals().iteritems(): + _gdict_ = globals().copy() + for name, c in _gdict_.iteritems(): if not inspect.isclass(c): continue if not issubclass(c, system_info) or c is system_info: From numpy-svn at scipy.org Fri Jun 30 07:59:31 2006 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 30 Jun 2006 06:59:31 -0500 (CDT) Subject: [Numpy-svn] r2708 - in trunk/numpy/lib: . tests Message-ID: <20060630115931.1C926D40AD5@new.scipy.org> Author: stefan Date: 2006-06-30 06:59:07 -0500 (Fri, 30 Jun 2006) New Revision: 2708 Modified: trunk/numpy/lib/function_base.py trunk/numpy/lib/tests/test_function_base.py Log: Add docstring and tests for digitize. Modified: trunk/numpy/lib/function_base.py =================================================================== --- trunk/numpy/lib/function_base.py 2006-06-30 00:27:30 UTC (rev 2707) +++ trunk/numpy/lib/function_base.py 2006-06-30 11:59:07 UTC (rev 2708) @@ -21,11 +21,11 @@ from numpy.core.numerictypes import typecodes from numpy.lib.shape_base import atleast_1d from numpy.lib.twodim_base import diag -from _compiled_base import digitize, bincount, _insert, add_docstring +from _compiled_base import bincount, _insert, add_docstring +from _compiled_base import digitize as _digitize #end Fernando's utilities - def linspace(start, stop, num=50, endpoint=True, retstep=False): """Return evenly spaced numbers. @@ -378,6 +378,17 @@ else: return a[slice1]-a[slice2] +def digitize(x,bins): + """For each value in x, return the index of the bin to which it belongs. + + Each index i returned is such that bins[i-1] <= x < bins[i] if + bins is monotonically increasing, or bins [i-1] > x >= bins[i] if + bins is monotonically decreasing. + + Beyond the bounds of the bins 0 or len(bins) is returned as appropriate. + """ + return _digitize(x,bins) + def angle(z, deg=0): """Return the angle of the complex argument z. """ Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2006-06-30 00:27:30 UTC (rev 2707) +++ trunk/numpy/lib/tests/test_function_base.py 2006-06-30 11:59:07 UTC (rev 2708) @@ -8,7 +8,7 @@ from numpy.core import * del sys.path[0] -class test_any(ScipyTestCase): +class test_any(NumpyTestCase): def check_basic(self): y1 = [0,0,1,0] y2 = [0,0,0,0] @@ -23,7 +23,7 @@ assert_array_equal(sometrue(y1),[1,1,0]) assert_array_equal(sometrue(y1,axis=1),[0,1,1]) -class test_all(ScipyTestCase): +class test_all(NumpyTestCase): def check_basic(self): y1 = [0,1,1,0] y2 = [0,0,0,0] @@ -39,7 +39,7 @@ assert_array_equal(alltrue(y1),[0,0,1]) assert_array_equal(alltrue(y1,axis=1),[0,0,1]) -class test_average(ScipyTestCase): +class test_average(NumpyTestCase): def check_basic(self): y1 = array([1,2,3]) assert(average(y1) == 2.) @@ -58,7 +58,7 @@ assert_array_equal(y5.mean(0), average(y5, 0)) assert_array_equal(y5.mean(1), average(y5, 1)) -class test_logspace(ScipyTestCase): +class test_logspace(NumpyTestCase): def check_basic(self): y = logspace(0,6) assert(len(y)==50) @@ -69,7 +69,7 @@ y = logspace(0,6,num=7) assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6]) -class test_linspace(ScipyTestCase): +class test_linspace(NumpyTestCase): def check_basic(self): y = linspace(0,10) assert(len(y)==50) @@ -94,7 +94,7 @@ assert_equal(t1, t2) assert_equal(t2, t3) -class test_amax(ScipyTestCase): +class test_amax(NumpyTestCase): def check_basic(self): a = [3,4,5,10,-3,-5,6.0] assert_equal(amax(a),10.0) @@ -104,7 +104,7 @@ assert_equal(amax(b,axis=0),[8.0,10.0,9.0]) assert_equal(amax(b,axis=1),[9.0,10.0,8.0]) -class test_amin(ScipyTestCase): +class test_amin(NumpyTestCase): def check_basic(self): a = [3,4,5,10,-3,-5,6.0] assert_equal(amin(a),-5.0) @@ -114,7 +114,7 @@ assert_equal(amin(b,axis=0),[3.0,3.0,2.0]) assert_equal(amin(b,axis=1),[3.0,4.0,2.0]) -class test_ptp(ScipyTestCase): +class test_ptp(NumpyTestCase): def check_basic(self): a = [3,4,5,10,-3,-5,6.0] assert_equal(ptp(a),15.0) @@ -124,7 +124,7 @@ assert_equal(ptp(b,axis=0),[5.0,7.0,7.0]) assert_equal(ptp(b,axis=-1),[6.0,6.0,6.0]) -class test_cumsum(ScipyTestCase): +class test_cumsum(NumpyTestCase): def check_basic(self): ba = [1,2,10,11,6,5,4] ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]] @@ -140,7 +140,7 @@ [5,11,18,27], [10,13,17,22]],ctype)) -class test_prod(ScipyTestCase): +class test_prod(NumpyTestCase): def check_basic(self): ba = [1,2,10,11,6,5,4] ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]] @@ -158,7 +158,7 @@ array([50,36,84,180],ctype)) assert_array_equal(prod(a2,axis=-1),array([24, 1890, 600],ctype)) -class test_cumprod(ScipyTestCase): +class test_cumprod(NumpyTestCase): def check_basic(self): ba = [1,2,10,11,6,5,4] ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]] @@ -183,7 +183,7 @@ [ 5, 30, 210, 1890], [10, 30, 120, 600]],ctype)) -class test_diff(ScipyTestCase): +class test_diff(NumpyTestCase): def check_basic(self): x = [1,4,6,7,12] out = array([3,2,1,5]) @@ -204,7 +204,7 @@ assert_array_equal(diff(x,axis=0),out3) assert_array_equal(diff(x,n=2,axis=0),out4) -class test_angle(ScipyTestCase): +class test_angle(NumpyTestCase): def check_basic(self): x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j] y = angle(x) @@ -215,7 +215,7 @@ assert_array_almost_equal(y,yo,11) assert_array_almost_equal(z,zo,11) -class test_trim_zeros(ScipyTestCase): +class test_trim_zeros(NumpyTestCase): """ only testing for integer splits. """ def check_basic(self): @@ -232,7 +232,7 @@ assert_array_equal(res,array([1,0,2,3,0,4])) -class test_extins(ScipyTestCase): +class test_extins(NumpyTestCase): def check_basic(self): a = array([1,3,2,1,2,3,3]) b = extract(a>1,a) @@ -250,7 +250,7 @@ insert(a,mask,c) assert_array_equal(a,ac) -class test_vectorize(ScipyTestCase): +class test_vectorize(NumpyTestCase): def check_simple(self): def addsubtract(a,b): if a > b: @@ -274,9 +274,19 @@ f = vectorize(lambda x: x) y = f(x) assert_array_equal(y, x) - -class test_unwrap(ScipyTestCase): +class test_digitize(NumpyTestCase): + def check_forward(self): + x = arange(-6,5) + bins = arange(-5,5) + assert_array_equal(digitize(x,bins),arange(11)) + + def check_reverse(self): + x = arange(5,-6,-1) + bins = arange(5,-5,-1) + assert_array_equal(digitize(x,bins),arange(11)) + +class test_unwrap(NumpyTestCase): def check_simple(self): #check that unwrap removes jumps greather that 2*pi assert_array_equal(unwrap([1,1+2*pi]),[1,1]) @@ -284,7 +294,7 @@ assert(all(diff(unwrap(rand(10)*100)) Author: stefan Date: 2006-06-30 07:21:17 -0500 (Fri, 30 Jun 2006) New Revision: 2709 Modified: trunk/numpy/lib/src/_compiled_base.c trunk/numpy/lib/tests/test_function_base.py Log: Cast to double instead of float in digitize. Modified: trunk/numpy/lib/src/_compiled_base.c =================================================================== --- trunk/numpy/lib/src/_compiled_base.c 2006-06-30 11:59:07 UTC (rev 2708) +++ trunk/numpy/lib/src/_compiled_base.c 2006-06-30 12:21:17 UTC (rev 2709) @@ -190,11 +190,11 @@ m = monotonic_ (dbins, lbins) ; if ( m == -1 ) { for ( i = 0 ; i < lx ; i ++ ) - iret [i] = decr_slot_ (dx [i], dbins, lbins) ; + iret [i] = decr_slot_ ((double)dx [i], dbins, lbins) ; } else if ( m == 1 ) { for ( i = 0 ; i < lx ; i ++ ) - iret [i] = incr_slot_ ((float)dx [i], dbins, lbins) ; + iret [i] = incr_slot_ ((double)dx [i], dbins, lbins) ; } else Py_Assert(0, "bins must be montonically increasing or decreasing"); } Modified: trunk/numpy/lib/tests/test_function_base.py =================================================================== --- trunk/numpy/lib/tests/test_function_base.py 2006-06-30 11:59:07 UTC (rev 2708) +++ trunk/numpy/lib/tests/test_function_base.py 2006-06-30 12:21:17 UTC (rev 2709) @@ -285,6 +285,11 @@ x = arange(5,-6,-1) bins = arange(5,-5,-1) assert_array_equal(digitize(x,bins),arange(11)) + + def check_random(self): + x = rand(10) + bin = linspace(x.min(), x.max(), 10) + assert all(digitize(x,bin) != 0) class test_unwrap(NumpyTestCase): def check_simple(self): From numpy-svn at scipy.org Fri Jun 30 09:29:04 2006 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 30 Jun 2006 08:29:04 -0500 (CDT) Subject: [Numpy-svn] r2710 - in trunk/numpy/f2py/lib: . research research/rat Message-ID: <20060630132904.66FBFD40B11@new.scipy.org> Author: pearu Date: 2006-06-30 08:28:59 -0500 (Fri, 30 Jun 2006) New Revision: 2710 Added: trunk/numpy/f2py/lib/research/ trunk/numpy/f2py/lib/research/rat/ trunk/numpy/f2py/lib/research/rat/main.c trunk/numpy/f2py/lib/research/rat/main.f90 trunk/numpy/f2py/lib/research/rat/rational.f90 Log: Workout a way to access Fortran derived objects from C. Added: trunk/numpy/f2py/lib/research/rat/main.c =================================================================== --- trunk/numpy/f2py/lib/research/rat/main.c 2006-06-30 12:21:17 UTC (rev 2709) +++ trunk/numpy/f2py/lib/research/rat/main.c 2006-06-30 13:28:59 UTC (rev 2710) @@ -0,0 +1,38 @@ + +#include +#include +#include + +typedef void* obj_type; +typedef obj_type (*rat_create_func)(void); +typedef obj_type (*rat_add_func)(obj_type, obj_type); +typedef void (*rat_show_func)(obj_type); +typedef void (*rat_set_func)(obj_type, int*, int*); + +static void** rational_funcs; + +static void set_f90_funcs2(int* n,...) { + int i; + va_list ap; + //printf("In set_f90_funcs n=%d\n",(*n)); + va_start(ap,n); + rational_funcs = (void*)malloc((*n)*sizeof(void*)); + for (i=0;i<(*n);i++) + rational_funcs[i] = va_arg(ap,void*); + va_end(ap); +} + +int main(void) { + init_f90_funcs_(set_f90_funcs2); + rat_create_func rat_create = rational_funcs[0]; + rat_show_func rat_show = rational_funcs[1]; + rat_set_func rat_set = rational_funcs[2]; + rat_add_func rat_add = rational_funcs[3]; + + obj_type obj_ptr = NULL; + obj_ptr = (*rat_create)(); + int n=2,d=3; + (*rat_set)(obj_ptr, &n, &d); + (*rat_show)(obj_ptr); + (*rat_show)((*rat_add)(obj_ptr,obj_ptr)); +} Added: trunk/numpy/f2py/lib/research/rat/main.f90 =================================================================== --- trunk/numpy/f2py/lib/research/rat/main.f90 2006-06-30 12:21:17 UTC (rev 2709) +++ trunk/numpy/f2py/lib/research/rat/main.f90 2006-06-30 13:28:59 UTC (rev 2710) @@ -0,0 +1,16 @@ + +program a + + use rational + + type(rat_struct), pointer :: r + + r => rat_create() + + print*,r + + call rat_set(r, 3,4) + + call rat_show(r) + +end program a Added: trunk/numpy/f2py/lib/research/rat/rational.f90 =================================================================== --- trunk/numpy/f2py/lib/research/rat/rational.f90 2006-06-30 12:21:17 UTC (rev 2709) +++ trunk/numpy/f2py/lib/research/rat/rational.f90 2006-06-30 13:28:59 UTC (rev 2710) @@ -0,0 +1,48 @@ + +module rational + + implicit none + + type, public :: rat_struct + integer :: numer ! numerator + integer :: denom ! denominator + end type rat_struct + + contains + + function rat_create() result (obj) + type(rat_struct), pointer :: obj + print*,'In rat_create' + allocate(obj) + call rat_set(obj, 0, 1) + end function rat_create + + subroutine rat_set(obj, n, d) + type(rat_struct) :: obj + integer :: n,d + print*,'In rat_set' + obj % numer = n + obj % denom = d + end subroutine rat_set + + subroutine rat_show(obj) + type(rat_struct) :: obj + print*,'In rat_show' + print*, "object numer,denom = ",obj % numer, obj % denom + end subroutine rat_show + + function rat_add(a,b) result (ab) + type(rat_struct), pointer :: ab + type(rat_struct) :: a,b + allocate(ab) + ab % numer = a % numer * b % denom + b % numer * a % denom + ab % denom = a % denom * b % denom + end function rat_add + +end module rational + +subroutine init_f90_funcs(set_f90_funcs) + use rational + external set_f90_funcs + call set_f90_funcs(4, rat_create, rat_show, rat_set, rat_add) +end subroutine init_f90_funcs From numpy-svn at scipy.org Fri Jun 30 09:36:23 2006 From: numpy-svn at scipy.org (numpy-svn at scipy.org) Date: Fri, 30 Jun 2006 08:36:23 -0500 (CDT) Subject: [Numpy-svn] r2711 - trunk/numpy/f2py/lib Message-ID: <20060630133623.EBE43D40B15@new.scipy.org> Author: pearu Date: 2006-06-30 08:36:13 -0500 (Fri, 30 Jun 2006) New Revision: 2711 Added: trunk/numpy/f2py/lib/test_parser.py Modified: trunk/numpy/f2py/lib/base_classes.py trunk/numpy/f2py/lib/block_statements.py trunk/numpy/f2py/lib/parsefortran.py trunk/numpy/f2py/lib/readfortran.py trunk/numpy/f2py/lib/splitline.py trunk/numpy/f2py/lib/statements.py trunk/numpy/f2py/lib/typedecl_statements.py Log: Writting parser unittests, fixed bugs. Modified: trunk/numpy/f2py/lib/base_classes.py =================================================================== --- trunk/numpy/f2py/lib/base_classes.py 2006-06-30 13:28:59 UTC (rev 2710) +++ trunk/numpy/f2py/lib/base_classes.py 2006-06-30 13:36:13 UTC (rev 2711) @@ -27,7 +27,7 @@ self.process_item() - def get_indent_tab(self,colon='',deindent=False): + def get_indent_tab(self,colon=None,deindent=False): if self.reader.isfix: tab = ' '*6 else: @@ -41,6 +41,11 @@ if self.item is None: return tab s = self.item.label + if colon is None: + if self.reader.isfix: + colon = '' + else: + colon = ':' if s: c = '' if self.reader.isfix: Modified: trunk/numpy/f2py/lib/block_statements.py =================================================================== --- trunk/numpy/f2py/lib/block_statements.py 2006-06-30 13:28:59 UTC (rev 2710) +++ trunk/numpy/f2py/lib/block_statements.py 2006-06-30 13:36:13 UTC (rev 2711) @@ -22,6 +22,9 @@ end_stmt_cls = EndSource + def tostr(self): + return '!' + self.blocktype.upper() + ' '+ self.name + def process_item(self): self.name = self.reader.name self.fill(end_flag = True) @@ -383,7 +386,8 @@ def tostr(self): return 'FORALL (%s)' % (self.specs) def get_classes(self): - return [Assignment, WhereStmt, WhereConstruct, ForallConstruct, ForallStmt] + return [GeneralAssignment, WhereStmt, WhereConstruct, + ForallConstruct, ForallStmt] ForallConstruct = Forall @@ -569,14 +573,14 @@ if line.startswith('('): self.isvalid = False return - attr_specs = [] + specs = [] i = line.find('::') if i!=-1: for s in line[:i].split(','): s = s.strip() - if s: attr_specs.append(s) + if s: specs.append(s) line = line[i+2:].lstrip() - self.attr_specs = attr_specs + self.specs = specs i = line.find('(') if i!=-1: self.name = line[:i].rstrip() @@ -592,15 +596,16 @@ def tostr(self): s = 'TYPE' - if self.attr_specs: - s += ', '.join(['']+self.attr_specs) + ' ::' + if self.specs: + s += ', '.join(['']+self.specs) + ' ::' s += ' ' + self.name if self.params: s += ' ('+self.params+')' return s def get_classes(self): - return [Integer] + private_or_sequence + component_part + type_bound_procedure_part + return [Integer] + private_or_sequence + component_part +\ + type_bound_procedure_part TypeDecl = Type @@ -652,6 +657,8 @@ DoublePrecision, Complex, DoubleComplex, Character, Logical, Byte ] +derived_type_spec = [ ] +type_spec = intrinsic_type_spec + derived_type_spec declaration_type_spec = intrinsic_type_spec + [ TypeStmt, Class ] type_declaration_stmt = declaration_type_spec @@ -665,12 +672,13 @@ type_bound_procedure_part = [Contains, Private] + proc_binding_stmt #R214 -action_stmt = [ Allocate, Assignment, Assign, Backspace, Call, Close, +action_stmt = [ Allocate, GeneralAssignment, Assign, Backspace, Call, Close, Continue, Cycle, Deallocate, Endfile, Exit, Flush, ForallStmt, Goto, If, Inquire, Nullify, Open, Print, Read, Return, Rewind, Stop, Wait, WhereStmt, Write, ArithmeticIf, ComputedGoto, AssignedGoto, Pause ] -#PointerAssignment,EndFunction, EndProgram, EndSubroutine, +# GeneralAssignment = Assignment + PointerAssignment +# EndFunction, EndProgram, EndSubroutine - part of the corresponding blocks executable_construct = [ Associate, Do, ForallConstruct, IfThen, Select, WhereConstruct ] + action_stmt Modified: trunk/numpy/f2py/lib/parsefortran.py =================================================================== --- trunk/numpy/f2py/lib/parsefortran.py 2006-06-30 13:28:59 UTC (rev 2710) +++ trunk/numpy/f2py/lib/parsefortran.py 2006-06-30 13:36:13 UTC (rev 2711) @@ -22,22 +22,22 @@ def __init__(self, reader): self.reader = reader - self.isfix77 = reader.isfix77 + return def get_item(self): try: - item = self.reader.next(ignore_comments = True) - return item + return self.reader.next(ignore_comments = True) except StopIteration: pass + return def put_item(self, item): self.reader.fifo_item.insert(0, item) + return def parse(self): try: - main = BeginSource(self) - return main + return BeginSource(self) except KeyboardInterrupt: raise except: @@ -50,6 +50,7 @@ reader = reader.reader traceback.print_exc(file=sys.stdout) self.reader.show_message(red_text('STOPPED PARSING'), sys.stdout) + return def test_pyf(): string = """ @@ -121,7 +122,6 @@ for filename in sys.argv[1:]: reader = FortranFileReader(filename) print yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode)) - parser = FortranParser(reader) block = parser.parse() #print block @@ -137,13 +137,13 @@ stats.print_stats(30) def parse_all_f(): - for filename in open('opt_all_f90.txt'): + for filename in open('opt_all_f.txt'): filename = filename.strip() reader = FortranFileReader(filename) - #print yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode)) - + print yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode)) parser = FortranParser(reader) block = parser.parse() + print block if __name__ == "__main__": #test_f77() Modified: trunk/numpy/f2py/lib/readfortran.py =================================================================== --- trunk/numpy/f2py/lib/readfortran.py 2006-06-30 13:28:59 UTC (rev 2710) +++ trunk/numpy/f2py/lib/readfortran.py 2006-06-30 13:36:13 UTC (rev 2711) @@ -51,7 +51,7 @@ """ Holds a Fortran source line. """ - f2py_strmap_findall = re.compile(r'( _F2PY_STRING_CONSTANT_\d+_ |\(F2PY_EXPR_TUPLE_\d+\))').findall + f2py_strmap_findall = re.compile(r'(_F2PY_STRING_CONSTANT_\d+_|F2PY_EXPR_TUPLE_\d+)').findall def __init__(self, line, linenospan, label, reader): self.line = line.strip() @@ -61,8 +61,12 @@ self.strline = None self.is_f2py_directive = linenospan[0] in reader.f2py_comment_lines + def has_map(self): + return not not (hasattr(self,'strlinemap') and self.strlinemap) + def apply_map(self, line): - if not hasattr(self,'strlinemap'): return line + if not hasattr(self,'strlinemap') or not self.strlinemap: + return line findall = self.f2py_strmap_findall str_map = self.strlinemap keys = findall(line) Modified: trunk/numpy/f2py/lib/splitline.py =================================================================== --- trunk/numpy/f2py/lib/splitline.py 2006-06-30 13:28:59 UTC (rev 2710) +++ trunk/numpy/f2py/lib/splitline.py 2006-06-30 13:36:13 UTC (rev 2711) @@ -28,7 +28,9 @@ """ return LineSplitter(line,lower=lower).split2() -_f2py_str_findall = re.compile(r"'_F2PY_STRING_CONSTANT_\d+_'").findall +_f2py_str_findall = re.compile(r"_F2PY_STRING_CONSTANT_\d+_").findall +_is_name = re.compile(r'\w*\Z',re.I).match +_is_simple_str = re.compile(r'\w*\Z',re.I).match def string_replace_map(line, lower=False, _cache={'index':0,'pindex':0}): @@ -41,31 +43,33 @@ string_map = {} rev_string_map = {} for item in splitquote(line, lower=lower)[0]: - if isinstance(item, String): + if isinstance(item, String) and not _is_simple_str(item[1:-1]): key = rev_string_map.get(item) if key is None: _cache['index'] += 1 index = _cache['index'] - key = "'_F2PY_STRING_CONSTANT_%s_'" % (index) - string_map[key] = item - rev_string_map[item] = key - items.append(key) + key = "_F2PY_STRING_CONSTANT_%s_" % (index) + it = item[1:-1] + string_map[key] = it + rev_string_map[it] = key + items.append(item[0]+key+item[-1]) else: items.append(item) newline = ''.join(items) items = [] expr_keys = [] for item in splitparen(newline): - if isinstance(item, ParenString): + if isinstance(item, ParenString) and not _is_name(item[1:-1]): key = rev_string_map.get(item) if key is None: _cache['pindex'] += 1 index = _cache['pindex'] - key = '(F2PY_EXPR_TUPLE_%s)' % (index) - string_map[key] = item - rev_string_map[item] = key + key = 'F2PY_EXPR_TUPLE_%s' % (index) + it = item[1:-1] + string_map[key] = it + rev_string_map[it] = key expr_keys.append(key) - items.append(key) + items.append(item[0]+key+item[-1]) else: items.append(item) found_keys = set() Modified: trunk/numpy/f2py/lib/statements.py =================================================================== --- trunk/numpy/f2py/lib/statements.py 2006-06-30 13:28:59 UTC (rev 2710) +++ trunk/numpy/f2py/lib/statements.py 2006-06-30 13:36:13 UTC (rev 2711) @@ -4,11 +4,55 @@ from base_classes import Statement +# Auxiliary tools + is_name = re.compile(r'\w+\Z').match +def split_comma(line, item): + newitem = item.copy(line, True) + apply_map = newitem.apply_map + items = [] + for s in newitem.get_line().split(','): + s = apply_map(s).strip() + if not s: continue + items.append(s) + return items + +def specs_split_comma(line, item): + specs0 = split_comma(line, item) + specs = [] + for spec in specs0: + i = spec.find('=') + if i!=-1: + kw = spec[:i].strip().upper() + v = spec[i+1:].strip() + specs.append('%s = %s' % (kw, v)) + else: + specs.append(spec) + return specs + +class StatementWithNamelist(Statement): + """ + [ :: ] + """ + def process_item(self): + assert not self.item.has_map() + clsname = self.__class__.__name__.lower() + line = self.item.get_line()[len(clsname):].lstrip() + if line.startswith('::'): + line = line[2:].lstrip() + self.items = [s.strip() for s in line.split(',')] + return + def __str__(self): + clsname = self.__class__.__name__.upper() + s = ', '.join(self.items) + if s: + s = ' ' + s + return self.get_indent_tab() + clsname + s + # Execution statements -class Assignment(Statement): +class GeneralAssignment(Statement): """ = => @@ -19,15 +63,36 @@ def process_item(self): m = self.item_re(self.item.get_line()) - self.variable = m.group('variable').replace(' ','') - self.sign = m.group('sign') - self.expr = m.group('expr') + if not m: + self.isvalid = False + return + self.sign = sign = m.group('sign') + if isinstance(self, Assignment) and sign != '=': + self.isvalid = False + return + elif isinstance(self, PointerAssignment) and sign != '=>': + self.isvalid = False + return + else: + if sign=='=>': + self.__class__ = PointerAssignment + else: + self.__class__ = Assignment + apply_map = self.item.apply_map + self.variable = apply_map(m.group('variable').replace(' ','')) + self.expr = apply_map(m.group('expr')) return def __str__(self): return self.get_indent_tab() + '%s %s %s' \ % (self.variable, self.sign, self.expr) +class Assignment(GeneralAssignment): + pass + +class PointerAssignment(GeneralAssignment): + pass + class Assign(Statement): """ ASSIGN