[Scipy-svn] r5489 - trunk/scipy/fftpack/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Jan 18 06:26:37 EST 2009
Author: cdavid
Date: 2009-01-18 05:26:28 -0600 (Sun, 18 Jan 2009)
New Revision: 5489
Modified:
trunk/scipy/fftpack/tests/test_real_transforms.py
Log:
Handle precision for equality tests in DCT tests.
Modified: trunk/scipy/fftpack/tests/test_real_transforms.py
===================================================================
--- trunk/scipy/fftpack/tests/test_real_transforms.py 2009-01-18 11:26:09 UTC (rev 5488)
+++ trunk/scipy/fftpack/tests/test_real_transforms.py 2009-01-18 11:26:28 UTC (rev 5489)
@@ -112,6 +112,7 @@
class _TestDCTIIBase(TestCase):
def setUp(self):
self.rdt = None
+ self.dec = 14
def test_definition(self):
for i in range(len(X)):
@@ -120,7 +121,7 @@
y = dct2(x)
self.failUnless(y.dtype == self.rdt,
"Output dtype is %s, expected %s" % (y.dtype, self.rdt))
- assert_array_almost_equal(y, yr)
+ assert_array_almost_equal(y, yr, decimal=self.dec)
def test_definition_ortho(self):
"""Test orthornomal mode."""
@@ -130,7 +131,7 @@
y = dct2(x, norm="ortho")
self.failUnless(y.dtype == self.rdt,
"Output dtype is %s, expected %s" % (y.dtype, self.rdt))
- assert_array_almost_equal(y, yr)
+ assert_array_almost_equal(y, yr, decimal=self.dec)
def test_axis(self):
nt = 2
@@ -138,24 +139,27 @@
x = np.random.randn(nt, i)
y = dct2(x)
for j in range(nt):
- assert_array_almost_equal(y[j], dct2(x[j]))
+ assert_array_almost_equal(y[j], dct2(x[j]), decimal=self.dec)
x = x.T
y = dct2(x, axis=0)
for j in range(nt):
- assert_array_almost_equal(y[:,j], dct2(x[:,j]))
+ assert_array_almost_equal(y[:,j], dct2(x[:,j]), decimal=self.dec)
class TestDCTIIDouble(_TestDCTIIBase):
def setUp(self):
self.rdt = np.double
+ self.dec = 10
class TestDCTIIFloat(_TestDCTIIBase):
def setUp(self):
- self.rdt = np.double
+ self.rdt = np.float32
+ self.dec = 5
class _TestDCTIIIBase(TestCase):
def setUp(self):
self.rdt = None
+ self.dec = 14
def test_definition(self):
for i in range(len(X)):
@@ -163,7 +167,8 @@
y = dct3(x)
self.failUnless(y.dtype == self.rdt,
"Output dtype is %s, expected %s" % (y.dtype, self.rdt))
- assert_array_almost_equal(dct2(y) / (2*x.size), x)
+ assert_array_almost_equal(dct2(y) / (2*x.size), x,
+ decimal=self.dec)
def test_definition_ortho(self):
"""Test orthornomal mode."""
@@ -173,7 +178,7 @@
xi = dct3(y, norm="ortho")
self.failUnless(xi.dtype == self.rdt,
"Output dtype is %s, expected %s" % (xi.dtype, self.rdt))
- assert_array_almost_equal(xi, x)
+ assert_array_almost_equal(xi, x, decimal=self.dec)
def test_axis(self):
nt = 2
@@ -181,16 +186,23 @@
x = np.random.randn(nt, i)
y = dct3(x)
for j in range(nt):
- assert_array_almost_equal(y[j], dct3(x[j]))
+ assert_array_almost_equal(y[j], dct3(x[j]), decimal=self.dec)
x = x.T
y = dct3(x, axis=0)
for j in range(nt):
- assert_array_almost_equal(y[:,j], dct3(x[:,j]))
+ assert_array_almost_equal(y[:,j], dct3(x[:,j]),
+ decimal=self.dec)
class TestDCTIIIDouble(_TestDCTIIIBase):
def setUp(self):
self.rdt = np.double
+ self.dec = 14
+class TestDCTIIIFloat(_TestDCTIIIBase):
+ def setUp(self):
+ self.rdt = np.float32
+ self.dec = 5
+
if __name__ == "__main__":
np.testing.run_module_suite()
More information about the Scipy-svn
mailing list