History

python/tests/test_phasevoc.py: check perfect reconstruction for overlap > 75%

Paul Brossier committed 10 years ago

Commit ac65a2f1 parent 1d0370a1 file · +26 −31Browse files

Showing the changes to python/tests (1 of 1 file). Show all

Unified · Split

python/tests/test_phasevoc.py+26−31
@@ -1,11 +1,12 @@
11 #! /usr/bin/env python
22
33 from numpy.testing import TestCase, assert_equal, assert_almost_equal
4−from aubio import fvec, cvec, pvoc
4+from aubio import fvec, cvec, pvoc, float_type
55 from numpy import array, shape
66 from numpy.random import random
7+import numpy as np
78
8−precision = 6
9+precision = 4
910
1011 class aubio_pvoc_test_case(TestCase):
1112 """ pvoc object test case """
@@ -38,38 +39,32 @@ class aubio_pvoc_test_case(TestCase): · 26 unmodified lines
3839 assert_equal ( s.phas, 0)
3940 assert_equal ( r, 0)
4041
41− def test_resynth_two_steps(self):
42− """ check the resynthesis of steps is correct with 50% overlap """
43− hop_s = 512
44− buf_s = hop_s * 2
42+ def test_resynth_8_steps(self):
43+ """ check the resynthesis of is correct with 87.5% overlap """
44+ hop_s = 256
45+ ratio = 8
46+ sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
47+ buf_s = hop_s * ratio
4548 f = pvoc(buf_s, hop_s)
46− sigin = fvec(hop_s)
47− zeros = fvec(hop_s)
48− # negative step
49− sigin[20:50] = -.1
50− # positive step
51− sigin[100:200] = .1
52− s1 = f(sigin)
53− r1 = f.rdo(s1)
54− s2 = f(zeros)
55− r2 = f.rdo(s2)
56− #self.plot_this ( s2.norm.T )
57− assert_almost_equal ( r2, sigin, decimal = precision )
58−
59− def test_resynth_three_steps(self):
60− """ check the resynthesis of steps is correct with 25% overlap """
61− hop_s = 16
62− buf_s = hop_s * 4
63− sigin = fvec(hop_s)
6449 zeros = fvec(hop_s)
50+ r2 = f.rdo( f(sigin) )
51+ for i in range(1, ratio):
52+ r2 = f.rdo( f(zeros) )
53+ r2 *= .5
54+ assert_almost_equal ( r2 - sigin, 0., decimal = precision )
55+
56+ def test_resynth_4_steps(self):
57+ """ check the resynthesis of is correct with 75% overlap """
58+ hop_s = 256
59+ ratio = 4
60+ sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
61+ buf_s = hop_s * ratio
6562 f = pvoc(buf_s, hop_s)
66− for i in range(hop_s):
67− sigin[i] = random() * 2. - 1.
68− t2 = f.rdo( f(sigin) )
69− t2 = f.rdo( f(zeros) )
70− t2 = f.rdo( f(zeros) )
71− t2 = f.rdo( f(zeros) )
72− assert_almost_equal( sigin, t2, decimal = precision )
63+ zeros = fvec(hop_s)
64+ r2 = f.rdo( f(sigin) )
65+ for i in range(1, ratio):
66+ r2 = f.rdo( f(zeros) )
67+ assert_almost_equal ( r2 - sigin, 0., decimal = precision )
7368
7469 def plot_this( self, this ):
7570 from pylab import semilogy, show

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t