Mercurial > hg > vampy-host
comparison test/test_process.py @ 70:ffdeb8808fc1
Let's favour consistent shape in output, and return the output identifier always
author | Chris Cannam |
---|---|
date | Wed, 14 Jan 2015 17:19:04 +0000 |
parents | b34d3b58da98 |
children | cb0380c92c42 |
comparison
equal
deleted
inserted
replaced
69:b34d3b58da98 | 70:ffdeb8808fc1 |
---|---|
48 # each feature has a single value, equal to the number of non-zero elts | 48 # each feature has a single value, equal to the number of non-zero elts |
49 # in the input block (which is all of them, i.e. the blocksize) plus | 49 # in the input block (which is all of them, i.e. the blocksize) plus |
50 # the first elt (which is i * blockSize + 1) | 50 # the first elt (which is i * blockSize + 1) |
51 # | 51 # |
52 expected = blocksize + i * blocksize + 1 | 52 expected = blocksize + i * blocksize + 1 |
53 actual = results[i]["values"][0] | 53 actual = results[i]["input-summary"]["values"][0] |
54 assert actual == expected | 54 assert actual == expected |
55 | 55 |
56 def test_process_freq_summary(): | 56 def test_process_freq_summary(): |
57 buf = input_data(blocksize * 10) | 57 buf = input_data(blocksize * 10) |
58 results = list(vamp.process(buf, rate, testPluginKeyFreq, {}, [ "input-summary" ])) | 58 results = list(vamp.process(buf, rate, testPluginKeyFreq, {}, [ "input-summary" ])) |
85 # | 85 # |
86 expected = i * (blocksize/2) + blocksize/2 + 1 # "first" elt | 86 expected = i * (blocksize/2) + blocksize/2 + 1 # "first" elt |
87 if (i == len(results)-1): | 87 if (i == len(results)-1): |
88 expected = 0 | 88 expected = 0 |
89 expected = expected + blocksize - 1 # non-zero elts | 89 expected = expected + blocksize - 1 # non-zero elts |
90 actual = results[i]["values"][0] | 90 actual = results[i]["input-summary"]["values"][0] |
91 eps = 1e-6 | 91 eps = 1e-6 |
92 assert abs(actual - expected) < eps | 92 assert abs(actual - expected) < eps |
93 | 93 |
94 def test_process_timestamps(): | 94 def test_process_timestamps(): |
95 buf = input_data(blocksize * 10) | 95 buf = input_data(blocksize * 10) |
97 assert len(results) == 10 | 97 assert len(results) == 10 |
98 for i in range(len(results)): | 98 for i in range(len(results)): |
99 # The timestamp should be the frame number of the first frame in the | 99 # The timestamp should be the frame number of the first frame in the |
100 # input buffer | 100 # input buffer |
101 expected = i * blocksize | 101 expected = i * blocksize |
102 actual = results[i]["values"][0] | 102 actual = results[i]["input-timestamp"]["values"][0] |
103 assert actual == expected | 103 assert actual == expected |
104 | 104 |
105 def test_process_freq_timestamps(): | 105 def test_process_freq_timestamps(): |
106 buf = input_data(blocksize * 10) | 106 buf = input_data(blocksize * 10) |
107 results = list(vamp.process(buf, rate, testPluginKeyFreq, {}, [ "input-timestamp" ])) | 107 results = list(vamp.process(buf, rate, testPluginKeyFreq, {}, [ "input-timestamp" ])) |
108 assert len(results) == 20 | 108 assert len(results) == 20 |
109 for i in range(len(results)): | 109 for i in range(len(results)): |
110 # The timestamp should be the frame number of the frame just beyond | 110 # The timestamp should be the frame number of the frame just beyond |
111 # half-way through the input buffer | 111 # half-way through the input buffer |
112 expected = i * (blocksize/2) + blocksize/2 | 112 expected = i * (blocksize/2) + blocksize/2 |
113 actual = results[i]["values"][0] | 113 actual = results[i]["input-timestamp"]["values"][0] |
114 print("actual = " + str(actual) + ", expected = " + str(expected)) | 114 print("actual = " + str(actual) + ", expected = " + str(expected)) |
115 assert actual == expected | 115 assert actual == expected |