[Scipy-svn] r6713 - trunk/scipy/optimize

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


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

Modified:
   trunk/scipy/optimize/zeros.c
Log:
3K: fix scipy.optimize._zeros wrapper for py3.

Modified: trunk/scipy/optimize/zeros.c
===================================================================
--- trunk/scipy/optimize/zeros.c	2010-09-12 00:48:02 UTC (rev 6712)
+++ trunk/scipy/optimize/zeros.c	2010-09-12 00:48:16 UTC (rev 6713)
@@ -178,15 +178,42 @@
 	{NULL, NULL}
 };
 
-PyMODINIT_FUNC init_zeros(void)
+static double __compute_relative_precision()
 {
-        double tol;
+    double tol;
 
-        /* Determine relative precision of doubles, assumes binary */
-        for(tol = 1; tol + 1 != 1; tol /= 2);
-        scipy_zeros_rtol = 2*tol;
+    /* Determine relative precision of doubles, assumes binary */
+    for(tol = 1; tol + 1 != 1; tol /= 2);
+    return 2*tol;
+}
 
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    "_zeros",
+    NULL,
+    -1,
+    Zerosmethods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
+
+PyObject *PyInit__zeros(void)
+{
+    PyObject *m, *d, *s;
+
+    m = PyModule_Create(&moduledef);
+
+    scipy_zeros_rtol = __compute_relative_precision();
+
+    return m;
+}
+#else
+PyMODINIT_FUNC init_zeros(void)
+{
         Py_InitModule("_zeros", Zerosmethods);
+        scipy_zeros_rtol = __compute_relative_precision();
 }
-
-
+#endif



More information about the Scipy-svn mailing list