[Scipy-svn] r6712 - in trunk: scipy/optimize tools

scipy-svn@scip... scipy-svn@scip...
Sat Sep 11 19:48:02 CDT 2010


Author: ptvirtan
Date: 2010-09-11 19:48:02 -0500 (Sat, 11 Sep 2010)
New Revision: 6712

Modified:
   trunk/scipy/optimize/_minpackmodule.c
   trunk/scipy/optimize/minpack.h
   trunk/tools/py3tool.py
Log:
3K: fix scipy.optimize._minpack wrapper for py3.

Modified: trunk/scipy/optimize/_minpackmodule.c
===================================================================
--- trunk/scipy/optimize/_minpackmodule.c	2010-09-12 00:47:47 UTC (rev 6711)
+++ trunk/scipy/optimize/_minpackmodule.c	2010-09-12 00:48:02 UTC (rev 6712)
@@ -13,6 +13,39 @@
 {"_chkder", minpack_chkder, METH_VARARGS, doc_chkder},
 {NULL,		NULL, 0, NULL}
 };
+
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    "_minpack",
+    NULL,
+    -1,
+    minpack_module_methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
+PyObject *PyInit__minpack(void)
+{
+    PyObject *m, *d, *s;
+
+    m = PyModule_Create(&moduledef);
+    import_array();
+
+    d = PyModule_GetDict(m);
+
+    s = PyUnicode_FromString(" 1.10 ");
+    PyDict_SetItemString(d, "__version__", s);
+    Py_DECREF(s);
+    minpack_error = PyErr_NewException ("minpack.error", NULL, NULL);
+    PyDict_SetItemString(d, "error", minpack_error);
+    if (PyErr_Occurred())
+        Py_FatalError("can't initialize module minpack");
+
+    return m;
+}
+#else
 PyMODINIT_FUNC init_minpack(void) {
   PyObject *m, *d, *s;
   m = Py_InitModule("_minpack", minpack_module_methods);
@@ -27,4 +60,4 @@
   if (PyErr_Occurred())
     Py_FatalError("can't initialize module minpack");
 }
-        
+#endif        

Modified: trunk/scipy/optimize/minpack.h
===================================================================
--- trunk/scipy/optimize/minpack.h	2010-09-12 00:47:47 UTC (rev 6711)
+++ trunk/scipy/optimize/minpack.h	2010-09-12 00:48:02 UTC (rev 6712)
@@ -29,6 +29,12 @@
 */
 
 #include "Python.h"
+#if PY_VERSION_HEX >= 0x03000000
+    #define PyString_FromString PyBytes_FromString
+    #define PyString_ConcatAndDel PyBytes_ConcatAndDel
+    #define PyString_AsString PyBytes_AsString
+    #define PyInt_FromLong PyLong_FromLong
+#endif
 #include "numpy/arrayobject.h"
 
 #define PYERR(errobj,message) {PyErr_SetString(errobj,message); goto fail;}

Modified: trunk/tools/py3tool.py
===================================================================
--- trunk/tools/py3tool.py	2010-09-12 00:47:47 UTC (rev 6711)
+++ trunk/tools/py3tool.py	2010-09-12 00:48:02 UTC (rev 6712)
@@ -146,6 +146,8 @@
         os.path.join('linalg', 'flinalg.py'),
         os.path.join('lib', 'blas', '__init__.py'),
         os.path.join('lib', 'lapack', '__init__.py'),
+        os.path.join('optimize', 'minpack.py'),
+        os.path.join('optimize', 'zeros.py'),
         os.path.join('special', '__init__.py'),
         os.path.join('special', 'basic.py'),
         os.path.join('special', 'orthogonal.py'),
@@ -160,7 +162,8 @@
         for mod in ['_vq', '_hierarchy_wrap', '_fftpack', 'convolve',
                     '_flinalg', 'fblas', 'flapack', 'cblas', 'clapack',
                     'calc_lwork', '_cephes', 'specfun', 'orthogonal_eval',
-                    'lambertw', 'ckdtree', '_distance_wrap']:
+                    'lambertw', 'ckdtree', '_distance_wrap',
+                    '_minpack', '_zeros']:
             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