[tests] improve onset coverage
authorPaul Brossier <piem@piem.org>
Sat, 17 Nov 2018 19:20:45 +0000 (20:20 +0100)
committerPaul Brossier <piem@piem.org>
Sat, 17 Nov 2018 19:20:45 +0000 (20:20 +0100)
python/tests/test_onset.py

index 8b5f7ba..b9cab6f 100755 (executable)
@@ -2,7 +2,7 @@
 
 from unittest import main
 from numpy.testing import TestCase, assert_equal, assert_almost_equal
-from aubio import onset
+from aubio import onset, fvec
 
 class aubio_onset_default(TestCase):
 
@@ -83,5 +83,37 @@ class aubio_onset_32000(aubio_onset_params):
 class aubio_onset_8000(aubio_onset_params):
     samplerate = 8000
 
+class aubio_onset_coverate(TestCase):
+    # extra tests to execute the C routines and improve coverage
+
+    def test_all_methods(self):
+        for method in ['default', 'energy', 'hfc', 'complexdomain', 'complex',
+                'phase', 'wphase', 'mkl', 'kl', 'specflux', 'specdiff',
+                'old_default']:
+            o = onset(method=method, buf_size=512, hop_size=256)
+            o(fvec(256))
+
+    def test_get_methods(self):
+        o = onset(method='default', buf_size=512, hop_size=256)
+
+        assert o.get_silence() == -70
+        o.set_silence(-20)
+        assert_almost_equal(o.get_silence(), -20)
+
+        assert o.get_compression() == 1
+        o.set_compression(.99)
+        assert_almost_equal(o.get_compression(), .99)
+
+        assert o.get_awhitening() == 0
+        o.set_awhitening(1)
+        assert o.get_awhitening() == 1
+
+        o.get_last()
+        o.get_last_ms()
+        o.get_last_s()
+        o.get_descriptor()
+        o.get_thresholded_descriptor()
+
+
 if __name__ == '__main__':
     main()