Skip to content

Commit

Permalink
3K: signal now builds and passes most tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
pv committed Sep 12, 2010
1 parent 09624c9 commit 5328199
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 17 deletions.
4 changes: 4 additions & 0 deletions scipy/signal/lfilter.c.src
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#define NO_IMPORT_ARRAY #define NO_IMPORT_ARRAY
#include <numpy/noprefix.h> #include <numpy/noprefix.h>


#if PY_VERSION_HEX >= 0x03000000
#define PyNumber_Divide PyNumber_TrueDivide
#endif

#include "sigtools.h" #include "sigtools.h"


static void FLOAT_filt(char *b, char *a, char *x, char *y, char *Z, static void FLOAT_filt(char *b, char *a, char *x, char *y, char *Z,
Expand Down
6 changes: 6 additions & 0 deletions scipy/signal/sigtools.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
#define _SCIPY_PRIVATE_SIGNAL_SIGTOOLS_H_ #define _SCIPY_PRIVATE_SIGNAL_SIGTOOLS_H_


#include "Python.h" #include "Python.h"

#if PY_VERSION_HEX >= 0x03000000
#define PyString_AsString PyBytes_AsString
#define PyString_FromFormat PyBytes_FromFormat
#endif

#include "numpy/noprefix.h" #include "numpy/noprefix.h"


#define BOUNDARY_MASK 12 #define BOUNDARY_MASK 12
Expand Down
31 changes: 29 additions & 2 deletions scipy/signal/sigtoolsmodule.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Permission to use, copy, modify, and distribute this software without fee
is granted under the SciPy License. is granted under the SciPy License.
*/ */
#include <Python.h> #include <Python.h>

#define PY_ARRAY_UNIQUE_SYMBOL _scipy_signal_ARRAY_API #define PY_ARRAY_UNIQUE_SYMBOL _scipy_signal_ARRAY_API
#include <numpy/noprefix.h> #include <numpy/noprefix.h>


Expand Down Expand Up @@ -822,10 +823,11 @@ COMPARE(ULONGLONG_compare, ulonglong)




int OBJECT_compare(PyObject **ip1, PyObject **ip2) { 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[] = \ CompareFunction compare_functions[] = \
{NULL, (CompareFunction)BYTE_compare,(CompareFunction)UBYTE_compare,\ {NULL, (CompareFunction)BYTE_compare,(CompareFunction)UBYTE_compare,\
Expand Down Expand Up @@ -1312,6 +1314,30 @@ static struct PyMethodDef toolbox_module_methods[] = {
{NULL, NULL, 0, NULL} /* sentinel */ {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) */ /* Initialization function for the module (*must* be called initsigtools) */


PyMODINIT_FUNC initsigtools(void) { PyMODINIT_FUNC initsigtools(void) {
Expand Down Expand Up @@ -1346,3 +1372,4 @@ PyMODINIT_FUNC initsigtools(void) {
Py_FatalError("can't initialize module array"); Py_FatalError("can't initialize module array");
} }
} }
#endif
49 changes: 34 additions & 15 deletions scipy/signal/splinemodule.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -469,7 +469,40 @@ static struct PyMethodDef toolbox_module_methods[] = {
}; };


/* Initialization function for the module (*must* be called initXXXXX) */ /* 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) { PyMODINIT_FUNC initspline(void) {
PyObject *m, *d, *s; PyObject *m, *d, *s;


Expand All @@ -490,18 +523,4 @@ PyMODINIT_FUNC initspline(void) {
if (PyErr_Occurred()) if (PyErr_Occurred())
Py_FatalError("can't initialize module array"); Py_FatalError("can't initialize module array");
} }

#endif














0 comments on commit 5328199

Please sign in to comment.