Showing the changes to python/tests (1 of 4 files). Show all
Unified · Split
| @@ -5,7 +5,7 @@ from numpy.testing.utils import assert_equal, assert_almost_equal · 4 unmodified lines | ||
| 5 | 5 | from numpy import cos, arange |
| 6 | 6 | from math import pi |
| 7 | 7 | |
| 8 | −from aubio import window, level_lin, db_spl, silence_detection | |
| 8 | +from aubio import window, level_lin, db_spl, silence_detection, level_detection | |
| 9 | 9 | |
| 10 | 10 | from aubio import fvec |
| 11 | 11 | |
| @@ -95,6 +95,26 @@ class aubio_silence_detection(TestCase): · 83 unmodified lines | ||
| 95 | 95 | from numpy import ones |
| 96 | 96 | assert silence_detection(ones(1024, dtype="float32"), -70) == 0 |
| 97 | 97 | |
| 98 | +class aubio_level_detection(TestCase): | |
| 99 | + def test_accept_fvec(self): | |
| 100 | + level_detection(fvec(1024), -70.) | |
| 101 | + | |
| 102 | + def test_fail_not_fvec(self): | |
| 103 | + try: | |
| 104 | + level_detection("default", -70) | |
| 105 | + except ValueError, e: | |
| 106 | + pass | |
| 107 | + else: | |
| 108 | + self.fail('non-number input phase does not raise a TypeError') | |
| 109 | + | |
| 110 | + def test_zeros_is_one(self): | |
| 111 | + from math import isinf | |
| 112 | + assert level_detection(fvec(1024), -70) == 1 | |
| 113 | + | |
| 114 | + def test_minus_ones_is_zero(self): | |
| 115 | + from numpy import ones | |
| 116 | + assert level_detection(ones(1024, dtype="float32"), -70) == 0 | |
| 117 | + | |
| 98 | 118 | if __name__ == '__main__': |
| 99 | 119 | from unittest import main |
| 100 | 120 | main() |