[python-dtcwt] 91/497: add tougher tolerance for perfect reconstruction test

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:05:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.

commit 59441d00a5a681dda979d004ceb1b4eefed8d218
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Fri Aug 9 15:36:25 2013 +0100

    add tougher tolerance for perfect reconstruction test
---
 tests/testifm1.py |  6 ++++--
 tests/testifm2.py |  8 +++++---
 tests/testxfm1.py | 11 ++++++++++-
 tests/testxfm2.py |  6 ++++--
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/tests/testifm1.py b/tests/testifm1.py
index f8a9b31..8b906fa 100644
--- a/tests/testifm1.py
+++ b/tests/testifm1.py
@@ -5,13 +5,15 @@ from nose.plugins.attrib import attr
 import numpy as np
 from dtcwt import dtwavexfm, dtwaveifm
 
+TOLERANCE = 1e-12
+
 @attr('transform')
 def test_reconstruct():
     # Reconstruction up to tolerance
     vec = np.random.rand(630)
     Yl, Yh = dtwavexfm(vec)
     vec_recon = dtwaveifm(Yl, Yh)
-    assert np.all(np.abs(vec_recon - vec) < 1e-7)
+    assert np.all(np.abs(vec_recon - vec) < TOLERANCE)
 
 @attr('transform')
 def test_reconstruct_2d():
@@ -19,6 +21,6 @@ def test_reconstruct_2d():
     vec = np.random.rand(630, 20)
     Yl, Yh = dtwavexfm(vec)
     vec_recon = dtwaveifm(Yl, Yh)
-    assert np.all(np.abs(vec_recon - vec) < 1e-7)
+    assert np.all(np.abs(vec_recon - vec) < TOLERANCE)
 
 # vim:sw=4:sts=4:et
diff --git a/tests/testifm2.py b/tests/testifm2.py
index 551cac2..b8906f0 100644
--- a/tests/testifm2.py
+++ b/tests/testifm2.py
@@ -5,6 +5,8 @@ from nose.plugins.attrib import attr
 import numpy as np
 from dtcwt import dtwavexfm2, dtwaveifm2, biort, qshift
 
+TOLERANCE = 1e-12
+
 def setup():
     global lena, lena_crop
     lena = np.load(os.path.join(os.path.dirname(__file__), 'lena.npz'))['lena']
@@ -21,21 +23,21 @@ def test_reconstruct():
     # Reconstruction up to tolerance
     Yl, Yh = dtwavexfm2(lena)
     lena_recon = dtwaveifm2(Yl, Yh)
-    assert np.all(np.abs(lena_recon - lena) < 1e-3)
+    assert np.all(np.abs(lena_recon - lena) < TOLERANCE)
 
 @attr('transform')
 def test_reconstruct_crop():
     # Reconstruction up to tolerance
     Yl_crop, Yh_crop = dtwavexfm2(lena_crop)
     lena_recon = dtwaveifm2(Yl_crop, Yh_crop)[:lena_crop.shape[0], :lena_crop.shape[1]]
-    assert np.all(np.abs(lena_recon - lena_crop) < 1e-3)
+    assert np.all(np.abs(lena_recon - lena_crop) < TOLERANCE)
 
 @attr('transform')
 def test_reconstruct_custom_filter():
     # Reconstruction up to tolerance
     Yl, Yh = dtwavexfm2(lena, 4, biort('legall'), qshift('qshift_06'))
     lena_recon = dtwaveifm2(Yl, Yh, biort('legall'), qshift('qshift_06'))
-    assert np.all(np.abs(lena_recon - lena) < 1e-3)
+    assert np.all(np.abs(lena_recon - lena) < TOLERANCE)
 
 
 # vim:sw=4:sts=4:et
diff --git a/tests/testxfm1.py b/tests/testxfm1.py
index 0d709eb..e9ef1ef 100644
--- a/tests/testxfm1.py
+++ b/tests/testxfm1.py
@@ -5,6 +5,8 @@ from nose.plugins.attrib import attr
 import numpy as np
 from dtcwt import dtwavexfm, dtwaveifm, biort, qshift
 
+TOLERANCE = 1e-12
+
 @attr('transform')
 def test_simple():
     vec = np.random.rand(630)
@@ -32,11 +34,18 @@ def test_simple_with_scale_and_no_levels():
     assert len(Yscale) == 0
 
 @attr('transform')
+def test_perfect_recon():
+    vec = np.random.rand(630)
+    Yl, Yh = dtwavexfm(vec)
+    vec_recon = dtwaveifm(Yl, Yh)
+    assert np.max(np.abs(vec_recon - vec)) < TOLERANCE
+
+ at attr('transform')
 def test_simple_custom_filter():
     vec = np.random.rand(630)
     Yl, Yh = dtwavexfm(vec, 4, biort('legall'), qshift('qshift_06'))
     vec_recon = dtwaveifm(Yl, Yh, biort('legall'), qshift('qshift_06'))
-    assert np.max(np.abs(vec_recon - vec)) < 1e-8
+    assert np.max(np.abs(vec_recon - vec)) < TOLERANCE
 
 @attr('transform')
 def test_single_level():
diff --git a/tests/testxfm2.py b/tests/testxfm2.py
index dbf05b4..ca4e96e 100644
--- a/tests/testxfm2.py
+++ b/tests/testxfm2.py
@@ -5,6 +5,8 @@ from nose.plugins.attrib import attr
 import numpy as np
 from dtcwt import dtwavexfm2, biort, qshift
 
+TOLERANCE = 1e-12
+
 def setup():
     global lena
     lena = np.load(os.path.join(os.path.dirname(__file__), 'lena.npz'))['lena']
@@ -52,12 +54,12 @@ def test_odd_rows_and_cols_w_scale():
 
 def test_0_levels():
     Yl, Yh = dtwavexfm2(lena, nlevels=0)
-    assert np.all(np.abs(Yl - lena) < 1e-5)
+    assert np.all(np.abs(Yl - lena) < TOLERANCE)
     assert len(Yh) == 0
 
 def test_0_levels_w_scale():
     Yl, Yh, Yscale = dtwavexfm2(lena, nlevels=0, include_scale=True)
-    assert np.all(np.abs(Yl - lena) < 1e-5)
+    assert np.all(np.abs(Yl - lena) < TOLERANCE)
     assert len(Yh) == 0
     assert len(Yscale) == 0
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git



More information about the debian-science-commits mailing list