Showing the changes to python/tests (1 of 1 file). Show all
Unified · Split
| @@ -1,9 +1,8 @@ | |||
| 1 | #! /usr/bin/env python | 1 | #! /usr/bin/env python |
| 2 | 2 | ||
| 3 | from numpy.testing import TestCase, assert_equal, assert_array_less | 3 | from numpy.testing import TestCase, assert_equal, assert_array_less |
| 4 | from ._tools import parametrize | ||
| 4 | from aubio import fvec, cvec, pvoc, float_type | 5 | from aubio import fvec, cvec, pvoc, float_type |
| 5 | from nose2 import main | ||
| 6 | from nose2.tools import params | ||
| 7 | import numpy as np | 6 | import numpy as np |
| 8 | 7 | ||
| 9 | if float_type == 'float32': | 8 | if float_type == 'float32': |
| @@ -18,7 +17,7 @@ def create_sine(hop_s, freq, samplerate): · 8 unmodified lines | |||
| 18 | def create_noise(hop_s): | 17 | def create_noise(hop_s): |
| 19 | return np.random.rand(hop_s).astype(float_type) * 2. - 1. | 18 | return np.random.rand(hop_s).astype(float_type) * 2. - 1. |
| 20 | 19 | ||
| 21 | class aubio_pvoc_test_case(TestCase): | 20 | class Test_aubio_pvoc_test_case: |
| 22 | """ pvoc object test case """ | 21 | """ pvoc object test case """ |
| 23 | 22 | ||
| 24 | def test_members_automatic_sizes_default(self): | 23 | def test_members_automatic_sizes_default(self): |
| @@ -56,7 +55,8 @@ class aubio_pvoc_test_case(TestCase): · 31 unmodified lines | |||
| 56 | + 'This is expected when using fftw3 on powerpc.') | 55 | + 'This is expected when using fftw3 on powerpc.') |
| 57 | assert_equal ( r, 0.) | 56 | assert_equal ( r, 0.) |
| 58 | 57 | ||
| 59 | @params( | 58 | resynth_noise_args = "hop_s, ratio" |
| 59 | resynth_noise_values = [ | ||
| 60 | ( 256, 8), | 60 | ( 256, 8), |
| 61 | ( 256, 4), | 61 | ( 256, 4), |
| 62 | ( 256, 2), | 62 | ( 256, 2), |
| @@ -78,13 +78,16 @@ class aubio_pvoc_test_case(TestCase): · 15 unmodified lines | |||
| 78 | (8192, 8), | 78 | (8192, 8), |
| 79 | (8192, 4), | 79 | (8192, 4), |
| 80 | (8192, 2), | 80 | (8192, 2), |
| 81 | ) | 81 | ] |
| 82 | |||
| 83 | @parametrize(resynth_noise_args, resynth_noise_values) | ||
| 82 | def test_resynth_steps_noise(self, hop_s, ratio): | 84 | def test_resynth_steps_noise(self, hop_s, ratio): |
| 83 | """ check the resynthesis of a random signal is correct """ | 85 | """ check the resynthesis of a random signal is correct """ |
| 84 | sigin = create_noise(hop_s) | 86 | sigin = create_noise(hop_s) |
| 85 | self.reconstruction(sigin, hop_s, ratio) | 87 | self.reconstruction(sigin, hop_s, ratio) |
| 86 | 88 | ||
| 87 | @params( | 89 | resynth_sine_args = "samplerate, hop_s, ratio, freq" |
| 90 | resynth_sine_values = [ | ||
| 88 | (44100, 256, 8, 441), | 91 | (44100, 256, 8, 441), |
| 89 | (44100, 256, 4, 1203), | 92 | (44100, 256, 4, 1203), |
| 90 | (44100, 256, 2, 3045), | 93 | (44100, 256, 2, 3045), |
| @@ -99,7 +102,9 @@ class aubio_pvoc_test_case(TestCase): · 8 unmodified lines | |||
| 99 | (22050, 256, 8, 445), | 102 | (22050, 256, 8, 445), |
| 100 | (96000, 1024, 8, 47000), | 103 | (96000, 1024, 8, 47000), |
| 101 | (96000, 1024, 8, 20), | 104 | (96000, 1024, 8, 20), |
| 102 | ) | 105 | ] |
| 106 | |||
| 107 | @parametrize(resynth_sine_args, resynth_sine_values) | ||
| 103 | def test_resynth_steps_sine(self, samplerate, hop_s, ratio, freq): | 108 | def test_resynth_steps_sine(self, samplerate, hop_s, ratio, freq): |
| 104 | """ check the resynthesis of a sine is correct """ | 109 | """ check the resynthesis of a sine is correct """ |
| 105 | sigin = create_sine(hop_s, freq, samplerate) | 110 | sigin = create_sine(hop_s, freq, samplerate) |
| @@ -190,5 +195,5 @@ class aubio_pvoc_wrong_params(TestCase): · 84 unmodified lines | |||
| 190 | self.skipTest('creating aubio.pvoc with size %d did not fail' % win_s) | 195 | self.skipTest('creating aubio.pvoc with size %d did not fail' % win_s) |
| 191 | 196 | ||
| 192 | if __name__ == '__main__': | 197 | if __name__ == '__main__': |
| 198 | from unittest import main | ||
| 193 | main() | 199 | main() |
| 194 | |||