[Scipy-svn] r6709 - in trunk: scipy/special tools

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Sep 11 20:47:15 EDT 2010


Author: ptvirtan
Date: 2010-09-11 19:47:15 -0500 (Sat, 11 Sep 2010)
New Revision: 6709

Modified:
   trunk/scipy/special/_cephesmodule.c
   trunk/tools/py3tool.py
Log:
3K: special now compiles, most tests pass.

Modified: trunk/scipy/special/_cephesmodule.c
===================================================================
--- trunk/scipy/special/_cephesmodule.c	2010-09-12 00:47:01 UTC (rev 6708)
+++ trunk/scipy/special/_cephesmodule.c	2010-09-12 00:47:15 UTC (rev 6709)
@@ -25,6 +25,12 @@
 
 #include "cephes_doc.h"
 
+#if PY_VERSION_HEX >= 0x03000000
+#define PyInt_FromLong PyLong_FromLong
+#define PyUString_FromString PyUnicode_FromString
+#else
+#define PyUString_FromString PyString_FromString
+#endif
 static PyUFuncGenericFunction cephes1_functions[] = { NULL, NULL, };
 static PyUFuncGenericFunction cephes1rc_functions[] = { NULL, NULL, NULL, NULL};
 static PyUFuncGenericFunction cephes1_2_functions[] = { NULL, NULL, NULL, NULL,};
@@ -1086,7 +1092,54 @@
   {NULL,		NULL, 0}		/* sentinel */
 };
 
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    "_cephes",
+    NULL,
+    -1,
+    methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
 
+PyObject *PyInit__cephes(void)
+{
+    PyObject *m, *s, *d;
+
+    m = PyModule_Create(&moduledef);
+    import_array();
+    import_ufunc();
+
+    /* Add some symbolic constants to the module */
+    d = PyModule_GetDict(m);
+
+    s = PyUString_FromString("2.0");
+    PyDict_SetItemString(d, "__version__", s);
+    Py_DECREF(s);
+
+    /* Add scipy_special_print_error_message global variable */
+    /*  No, instead acessible through errprint */
+
+    /* Load the cephes operators into the array module's namespace */
+    Cephes_InitOperators(d);
+
+    /* Register and add the warning type object */
+    scipy_special_SpecialFunctionWarning = PyErr_NewException(
+            "scipy.special._cephes.SpecialFunctionWarning",
+            PyExc_RuntimeWarning,
+            NULL);
+    PyModule_AddObject(m, "SpecialFunctionWarning",
+            scipy_special_SpecialFunctionWarning);
+
+    /* Check for errors */
+    if (PyErr_Occurred())
+        Py_FatalError("can't initialize module _cephes");
+    return m;
+}
+#else
 PyMODINIT_FUNC init_cephes(void) {
   PyObject *m, *d, *s;
 
@@ -1122,3 +1175,4 @@
   if (PyErr_Occurred())
     Py_FatalError("can't initialize module _cephes");
 }
+#endif

Modified: trunk/tools/py3tool.py
===================================================================
--- trunk/tools/py3tool.py	2010-09-12 00:47:01 UTC (rev 6708)
+++ trunk/tools/py3tool.py	2010-09-12 00:47:15 UTC (rev 6709)
@@ -146,6 +146,9 @@
         os.path.join('linalg', 'flinalg.py'),
         os.path.join('lib', 'blas', '__init__.py'),
         os.path.join('lib', 'lapack', '__init__.py'),
+        os.path.join('special', '__init__.py'),
+        os.path.join('special', 'basic.py'),
+        os.path.join('special', 'orthogonal.py'),
     ]
 
     if any(filename.endswith(x) for x in import_mangling):
@@ -153,7 +156,9 @@
         text = f.read()
         f.close()
         for mod in ['_vq', '_hierarchy_wrap', '_fftpack', 'convolve',
-                    '_flinalg', 'fblas', 'flapack', 'cblas', 'clapack',                    'calc_lwork']:
+                    '_flinalg', 'fblas', 'flapack', 'cblas', 'clapack',
+                    'calc_lwork', '_cephes', 'specfun', 'orthogonal_eval',
+                    'lambertw']:
             text = re.sub(r'^(\s*)import %s' % mod,
                           r'\1from . import %s' % mod,
                           text, flags=re.M)




More information about the Scipy-svn mailing list