Skip to content
Browse files

3K: signal now builds and passes most tests.

  • Loading branch information...
1 parent 09624c9 commit 53281998d389c91f231c41e0fc3fecb78dab2589 @pv pv committed
Showing with 73 additions and 17 deletions.
  1. +4 −0 scipy/signal/lfilter.c.src
  2. +6 −0 scipy/signal/sigtools.h
  3. +29 −2 scipy/signal/sigtoolsmodule.c
  4. +34 −15 scipy/signal/splinemodule.c
View
4 scipy/signal/lfilter.c.src
@@ -7,6 +7,10 @@
#define NO_IMPORT_ARRAY
#include <numpy/noprefix.h>
+#if PY_VERSION_HEX >= 0x03000000
+#define PyNumber_Divide PyNumber_TrueDivide
+#endif
+
#include "sigtools.h"
static void FLOAT_filt(char *b, char *a, char *x, char *y, char *Z,
View
6 scipy/signal/sigtools.h
@@ -2,6 +2,12 @@
#define _SCIPY_PRIVATE_SIGNAL_SIGTOOLS_H_
#include "Python.h"
+
+#if PY_VERSION_HEX >= 0x03000000
+ #define PyString_AsString PyBytes_AsString
+ #define PyString_FromFormat PyBytes_FromFormat
+#endif
+
#include "numpy/noprefix.h"
#define BOUNDARY_MASK 12
View
31 scipy/signal/sigtoolsmodule.c
@@ -5,6 +5,7 @@ Permission to use, copy, modify, and distribute this software without fee
is granted under the SciPy License.
*/
#include <Python.h>
+
#define PY_ARRAY_UNIQUE_SYMBOL _scipy_signal_ARRAY_API
#include <numpy/noprefix.h>
@@ -822,10 +823,11 @@ COMPARE(ULONGLONG_compare, ulonglong)
int OBJECT_compare(PyObject **ip1, PyObject **ip2) {
- return PyObject_Compare(*ip1, *ip2);
+ /*return PyObject_Compare(*ip1, *ip2); */
+ return PyObject_RichCompareBool(*ip1, *ip2, Py_EQ) != 1;
}
-typedef int (*CompareFunction) Py_FPROTO((const void *, const void *));
+typedef int (*CompareFunction)(const void *, const void *);
CompareFunction compare_functions[] = \
{NULL, (CompareFunction)BYTE_compare,(CompareFunction)UBYTE_compare,\
@@ -1312,6 +1314,30 @@ static struct PyMethodDef toolbox_module_methods[] = {
{NULL, NULL, 0, NULL} /* sentinel */
};
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "sigtools",
+ NULL,
+ -1,
+ toolbox_module_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+PyObject *PyInit_sigtools(void)
+{
+ PyObject *m, *d, *s;
+
+ m = PyModule_Create(&moduledef);
+ import_array();
+
+ scipy_signal_sigtools_linear_filter_module_init();
+
+ return m;
+}
+#else
/* Initialization function for the module (*must* be called initsigtools) */
PyMODINIT_FUNC initsigtools(void) {
@@ -1346,3 +1372,4 @@ PyMODINIT_FUNC initsigtools(void) {
Py_FatalError("can't initialize module array");
}
}
+#endif
View
49 scipy/signal/splinemodule.c
@@ -469,7 +469,40 @@ static struct PyMethodDef toolbox_module_methods[] = {
};
/* Initialization function for the module (*must* be called initXXXXX) */
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "spline",
+ NULL,
+ -1,
+ toolbox_module_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyObject *PyInit_spline(void)
+{
+ PyObject *m, *d, *s;
+
+ m = PyModule_Create(&moduledef);
+ import_array();
+
+ /* Add some symbolic constants to the module */
+ d = PyModule_GetDict(m);
+ s = PyUnicode_FromString("0.2");
+ PyDict_SetItemString(d, "__version__", s);
+ Py_DECREF(s);
+
+ /* Check for errors */
+ if (PyErr_Occurred()) {
+ Py_FatalError("can't initialize module array");
+ }
+ return m;
+}
+#else
PyMODINIT_FUNC initspline(void) {
PyObject *m, *d, *s;
@@ -490,18 +523,4 @@ PyMODINIT_FUNC initspline(void) {
if (PyErr_Occurred())
Py_FatalError("can't initialize module array");
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+#endif

0 comments on commit 5328199

Please sign in to comment.
Something went wrong with that request. Please try again.