#! /usr/bin/env python
from numpy.testing import TestCase, assert_equal, assert_array_less
+from _tools import parametrize, skipTest
from aubio import fvec, cvec, pvoc, float_type
-from nose2 import main
-from nose2.tools import params
import numpy as np
if float_type == 'float32':
def create_noise(hop_s):
return np.random.rand(hop_s).astype(float_type) * 2. - 1.
-class aubio_pvoc_test_case(TestCase):
+class Test_aubio_pvoc_test_case(object):
""" pvoc object test case """
def test_members_automatic_sizes_default(self):
assert_equal (s.phas[s.phas > 0], +np.pi)
assert_equal (s.phas[s.phas < 0], -np.pi)
assert_equal (np.abs(s.phas[np.abs(s.phas) != np.pi]), 0)
- self.skipTest('pvoc(fvec(%d)).phas != +0, ' % win_s \
+ skipTest('pvoc(fvec(%d)).phas != +0, ' % win_s \
+ 'This is expected when using fftw3 on powerpc.')
assert_equal ( r, 0.)
- @params(
+ def test_no_overlap(self):
+ win_s, hop_s = 1024, 1024
+ f = pvoc (win_s, hop_s)
+ t = fvec (hop_s)
+ for _ in range(4):
+ s = f(t)
+ r = f.rdo(s)
+ assert_equal ( t, 0.)
+
+ resynth_noise_args = "hop_s, ratio"
+ resynth_noise_values = [
( 256, 8),
( 256, 4),
( 256, 2),
(8192, 8),
(8192, 4),
(8192, 2),
- )
+ ]
+
+ @parametrize(resynth_noise_args, resynth_noise_values)
def test_resynth_steps_noise(self, hop_s, ratio):
""" check the resynthesis of a random signal is correct """
sigin = create_noise(hop_s)
self.reconstruction(sigin, hop_s, ratio)
- @params(
+ resynth_sine_args = "samplerate, hop_s, ratio, freq"
+ resynth_sine_values = [
(44100, 256, 8, 441),
(44100, 256, 4, 1203),
(44100, 256, 2, 3045),
(22050, 256, 8, 445),
(96000, 1024, 8, 47000),
(96000, 1024, 8, 20),
- )
+ ]
+
+ @parametrize(resynth_sine_args, resynth_sine_values)
def test_resynth_steps_sine(self, samplerate, hop_s, ratio, freq):
""" check the resynthesis of a sine is correct """
sigin = create_sine(hop_s, freq, samplerate)
self.skipTest('creating aubio.pvoc with size %d did not fail' % win_s)
if __name__ == '__main__':
+ from unittest import main
main()
-