[Scipy-svn] r7067 - trunk/scipy/signal/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Tue Jan 18 15:30:14 EST 2011


Author: warren.weckesser
Date: 2011-01-18 14:30:12 -0600 (Tue, 18 Jan 2011)
New Revision: 7067

Modified:
   trunk/scipy/signal/tests/test_signaltools.py
Log:
BUG/TST: The test of complex case of the correlate() function did not properly take into account the platform dependence of the longdouble type.

Modified: trunk/scipy/signal/tests/test_signaltools.py
===================================================================
--- trunk/scipy/signal/tests/test_signaltools.py	2011-01-16 15:23:36 UTC (rev 7066)
+++ trunk/scipy/signal/tests/test_signaltools.py	2011-01-18 20:30:12 UTC (rev 7067)
@@ -576,16 +576,16 @@
         self.assertTrue(y.dtype == self.dt)
 
 
-def _get_testcorrelate_class(i, base):
+def _get_testcorrelate_class(datatype, base):
     class TestCorrelateX(base):
-        dt = i
-    TestCorrelateX.__name__ = "TestCorrelate%s" % i.__name__.title()
+        dt = datatype
+    TestCorrelateX.__name__ = "TestCorrelate%s" % datatype.__name__.title()
     return TestCorrelateX
 
-for i in [np.ubyte, np.byte, np.ushort, np.short, np.uint, np.int,
+for datatype in [np.ubyte, np.byte, np.ushort, np.short, np.uint, np.int,
         np.ulonglong, np.ulonglong, np.float32, np.float64, np.longdouble,
         Decimal]:
-    cls = _get_testcorrelate_class(i, _TestCorrelateReal)
+    cls = _get_testcorrelate_class(datatype, _TestCorrelateReal)
     globals()[cls.__name__] = cls
 
 
@@ -683,13 +683,11 @@
         self.assertTrue(y.dtype == self.dt)
 
 
-# Create three classes, one for each complex data type: TestCorrelateComplex64,
-# TestCorrelateComplex128 and TestCorrelateComplex256.
-# The second number in the pairs is used in the 'decimal' keyword argument of
-# the  array comparisons in the tests.
-for i, decimal in [(np.csingle, 5), (np.cdouble, 10), (np.clongdouble, 15)]:
-    cls = _get_testcorrelate_class(i, _TestCorrelateComplex)
-    cls.decimal = decimal
+# Create three classes, one for each complex data type. The actual class
+# name will be TestCorrelateComplex###, where ### is the number of bits.
+for datatype in [np.csingle, np.cdouble, np.clongdouble]:
+    cls = _get_testcorrelate_class(datatype, _TestCorrelateComplex)
+    cls.decimal = int(2 * np.finfo(datatype).precision / 3)
     globals()[cls.__name__] = cls
 
 




More information about the Scipy-svn mailing list