[Scipy-svn] r6243 - trunk/scipy/signal

scipy-svn@scip... scipy-svn@scip...
Sun Feb 21 09:38:35 CST 2010


Author: ptvirtan
Date: 2010-02-21 09:38:35 -0600 (Sun, 21 Feb 2010)
New Revision: 6243

Modified:
   trunk/scipy/signal/lfilter.c.src
   trunk/scipy/signal/sigtools.h
   trunk/scipy/signal/sigtoolsmodule.c
Log:
BUG: signaltools: make lfilter work also after Numpy ABI change (value of NPY_OBJECT should not be hardcoded)

Modified: trunk/scipy/signal/lfilter.c.src
===================================================================
--- trunk/scipy/signal/lfilter.c.src	2010-02-19 11:02:12 UTC (rev 6242)
+++ trunk/scipy/signal/lfilter.c.src	2010-02-21 15:38:35 UTC (rev 6243)
@@ -33,13 +33,24 @@
 
 typedef void (BasicFilterFunction) (char *, char *,  char *, char *, char *, intp, uintp, intp, intp);
 
-static BasicFilterFunction *BasicFilterFunctions[] =
-    { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-    FLOAT_filt, DOUBLE_filt, EXTENDED_filt,
-    CFLOAT_filt, CDOUBLE_filt, CEXTENDED_filt,
-    OBJECT_filt, NULL, NULL, NULL
-};
+static BasicFilterFunction *BasicFilterFunctions[256];
 
+void
+scipy_signal_sigtools_linear_filter_module_init()
+{
+    int k;
+    for (k = 0; k < 256; ++k) {
+        BasicFilterFunctions[k] = NULL;
+    }
+    BasicFilterFunctions[NPY_FLOAT] = FLOAT_filt;
+    BasicFilterFunctions[NPY_DOUBLE] = DOUBLE_filt;
+    BasicFilterFunctions[NPY_LONGDOUBLE] = EXTENDED_filt;
+    BasicFilterFunctions[NPY_CFLOAT] = CFLOAT_filt;
+    BasicFilterFunctions[NPY_CDOUBLE] = CDOUBLE_filt;
+    BasicFilterFunctions[NPY_CLONGDOUBLE] = CEXTENDED_filt;
+    BasicFilterFunctions[NPY_OBJECT] = OBJECT_filt;
+}
+
 /* There is the start of an OBJECT_filt, but it may need work */
 
 static int
@@ -114,7 +125,12 @@
                                                    typenum);
     }
 
-    basic_filter = BasicFilterFunctions[(int) (arX->descr->type_num)];
+    if (arX->descr->type_num < 256) {
+        basic_filter = BasicFilterFunctions[(int) (arX->descr->type_num)];
+    }
+    else {
+        basic_filter = NULL;
+    }
     if (basic_filter == NULL) {
         PyObject *msg, *str;
         char *s;

Modified: trunk/scipy/signal/sigtools.h
===================================================================
--- trunk/scipy/signal/sigtools.h	2010-02-19 11:02:12 UTC (rev 6242)
+++ trunk/scipy/signal/sigtools.h	2010-02-21 15:38:35 UTC (rev 6243)
@@ -55,6 +55,9 @@
 PyObject*
 scipy_signal_sigtools_correlateND(PyObject *NPY_UNUSED(dummy), PyObject *args);
 
+void
+scipy_signal_sigtools_linear_filter_module_init();
+
 /*
 static int index_out_of_bounds(int *, int *, int );
 static long compute_offsets (unsigned long *, long *, int *, int *, int *, int *, int);

Modified: trunk/scipy/signal/sigtoolsmodule.c
===================================================================
--- trunk/scipy/signal/sigtoolsmodule.c	2010-02-19 11:02:12 UTC (rev 6242)
+++ trunk/scipy/signal/sigtoolsmodule.c	2010-02-21 15:38:35 UTC (rev 6243)
@@ -1338,6 +1338,7 @@
         PyDict_SetItemString(d,"HILBERT", PyInt_FromLong((long) HILBERT));
         */
 
+        scipy_signal_sigtools_linear_filter_module_init();
 
 	/* Check for errors */
 	if (PyErr_Occurred()) {



More information about the Scipy-svn mailing list