From dfada339fa13762a469cf4dba2c154a426bbecab Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 2 May 2016 12:02:06 +0200 Subject: [PATCH] python/tests/test_phasevoc.py: simplify, add wrong sized input tests --- python/tests/test_phasevoc.py | 75 ++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/python/tests/test_phasevoc.py b/python/tests/test_phasevoc.py index 70ae50eb..d4813452 100755 --- a/python/tests/test_phasevoc.py +++ b/python/tests/test_phasevoc.py @@ -2,8 +2,6 @@ from numpy.testing import TestCase, assert_equal, assert_array_less from aubio import fvec, cvec, pvoc, float_type -from numpy import array, shape -from numpy.random import random from nose2.tools import params import numpy as np @@ -50,51 +48,6 @@ class aubio_pvoc_test_case(TestCase): assert_equal ( s.phas, 0.) assert_equal ( r, 0.) - def test_resynth_8_steps_sine(self): - """ check the resynthesis of is correct with 87.5% overlap """ - hop_s = 1024 - ratio = 8 - freq = 445; samplerate = 22050 - sigin = create_sine(hop_s, freq, samplerate) - self.reconstruction( sigin, hop_s, ratio) - - def test_resynth_8_steps(self): - """ check the resynthesis of is correct with 87.5% overlap """ - hop_s = 1024 - ratio = 8 - sigin = create_noise(hop_s) - self.reconstruction(sigin, hop_s, ratio) - - def test_resynth_4_steps_sine(self): - """ check the resynthesis of is correct with 87.5% overlap """ - hop_s = 1024 - ratio = 4 - freq = 445; samplerate = 22050 - sigin = create_sine(hop_s, freq, samplerate) - self.reconstruction(sigin, hop_s, ratio) - - def test_resynth_4_steps(self): - """ check the resynthesis of is correct with 75% overlap """ - hop_s = 1024 - ratio = 4 - sigin = create_noise(hop_s) - self.reconstruction(sigin, hop_s, ratio) - - def test_resynth_2_steps_sine(self): - """ check the resynthesis of is correct with 50% overlap """ - hop_s = 1024 - ratio = 2 - freq = 445; samplerate = 22050 - sigin = create_sine(hop_s, freq, samplerate) - self.reconstruction(sigin, hop_s, ratio) - - def test_resynth_2_steps(self): - """ check the resynthesis of is correct with 50% overlap """ - hop_s = 1024 - ratio = 2 - sigin = create_noise(hop_s) - self.reconstruction(sigin, hop_s, ratio) - @params( ( 256, 8), ( 256, 4), @@ -153,6 +106,34 @@ class aubio_pvoc_test_case(TestCase): # make sure all square errors are less than desired precision assert_array_less(sq_error, max_sq_error) + def test_large_input_timegrain(self): + win_s = 1024 + f = pvoc(win_s) + t = fvec(win_s + 1) + with self.assertRaises(ValueError): + f(t) + + def test_small_input_timegrain(self): + win_s = 1024 + f = pvoc(win_s) + t = fvec(1) + with self.assertRaises(ValueError): + f(t) + + def test_large_input_fftgrain(self): + win_s = 1024 + f = pvoc(win_s) + s = cvec(win_s + 5) + with self.assertRaises(ValueError): + f.rdo(s) + + def test_small_input_fftgrain(self): + win_s = 1024 + f = pvoc(win_s) + s = cvec(16) + with self.assertRaises(ValueError): + f.rdo(s) + if __name__ == '__main__': from nose2 import main main() -- 2.11.0