ref: 8354cb8c70ed864e20477e36bdf505d6646ba328
parent: ed09ba7cf05fa3571625c0ecabeec20195ab3306
author: Paul Brossier <piem@piem.org>
date: Sat Nov 10 07:00:25 EST 2018
[py] add assert_warns to filterbank.set_triangle_bands tests
--- a/python/tests/test_filterbank_mel.py
+++ b/python/tests/test_filterbank_mel.py
@@ -75,8 +75,8 @@
samplerate = 22050
freq_list = [0, samplerate//4, samplerate // 2 + 1]
f = filterbank(len(freq_list)-2, 1024)
- # TODO add assert_warns
- f.set_triangle_bands(fvec(freq_list), samplerate)
+ with assert_warns(UserWarning):
+ f.set_triangle_bands(fvec(freq_list), samplerate)
def test_triangle_freqs_with_not_enough_filters(self):
"""make sure set_triangle_bands warns when not enough filters"""
@@ -83,8 +83,8 @@
samplerate = 22050
freq_list = [0, 100, 1000, 4000, 8000, 10000]
f = filterbank(len(freq_list)-3, 1024)
- # TODO add assert_warns
- f.set_triangle_bands(fvec(freq_list), samplerate)
+ with assert_warns(UserWarning):
+ f.set_triangle_bands(fvec(freq_list), samplerate)
def test_triangle_freqs_with_too_many_filters(self):
"""make sure set_triangle_bands warns when too many filters"""
@@ -91,8 +91,8 @@
samplerate = 22050
freq_list = [0, 100, 1000, 4000, 8000, 10000]
f = filterbank(len(freq_list)-1, 1024)
- # TODO add assert_warns
- f.set_triangle_bands(fvec(freq_list), samplerate)
+ with assert_warns(UserWarning):
+ f.set_triangle_bands(fvec(freq_list), samplerate)
def test_triangle_freqs_with_double_value(self):
"""make sure set_triangle_bands works with 2 duplicate freqs"""
@@ -99,8 +99,8 @@
samplerate = 22050
freq_list = [0, 100, 1000, 4000, 4000, 4000, 10000]
f = filterbank(len(freq_list)-2, 1024)
- # TODO add assert_warns
- f.set_triangle_bands(fvec(freq_list), samplerate)
+ with assert_warns(UserWarning):
+ f.set_triangle_bands(fvec(freq_list), samplerate)
def test_triangle_freqs_with_triple(self):
"""make sure set_triangle_bands works with 3 duplicate freqs"""
@@ -107,8 +107,8 @@
samplerate = 22050
freq_list = [0, 100, 1000, 4000, 4000, 4000, 10000]
f = filterbank(len(freq_list)-2, 1024)
- # TODO add assert_warns
- f.set_triangle_bands(fvec(freq_list), samplerate)
+ with assert_warns(UserWarning):
+ f.set_triangle_bands(fvec(freq_list), samplerate)
if __name__ == '__main__':