diff tests/test_load_features.py @ 34:115774aff442 branch-tests

music bounds not centered but aligned with start of segment to match the way features are computed
author Maria Panteli
date Thu, 14 Sep 2017 10:16:59 +0100
parents 0f3eba42b425
children c4428589b82b
line wrap: on
line diff
--- a/tests/test_load_features.py	Wed Sep 13 20:04:09 2017 +0100
+++ b/tests/test_load_features.py	Thu Sep 14 10:16:59 2017 +0100
@@ -19,14 +19,15 @@
     sr = feat_loader.framessr2            
     music_bounds = feat_loader.get_music_idx_from_bounds(bounds, sr=sr)
     # upper bound minus half window size
-    half_win_sec = 4.0  # assume 8-second window
-    music_bounds_true = np.arange(np.round(sr * (np.float(bounds[-1, 1]) - half_win_sec)), dtype=int)
+    #half_win_sec = 4.0  # assume 8-second window
+    win_sec = 8
+    music_bounds_true = np.arange(np.round(sr * (np.float(bounds[-1, 1]) - win_sec)), dtype=int)
     assert np.array_equal(music_bounds, music_bounds_true)
     
     
 def test_get_music_idx_from_bounds_short_segment():
     # anything less than half window size is not processed
-    bounds = np.array([['0', '3.8', 'm']])
+    bounds = np.array([['0', '7.9', 'm']])
     sr = feat_loader.framessr2
     music_bounds = feat_loader.get_music_idx_from_bounds(bounds, sr=sr)
     music_bounds_true = np.array([])
@@ -34,8 +35,8 @@
 
 
 def test_get_music_idx_from_bounds_single_frame():
-    bounds = np.array([['0', '4.3', 'm']])
-    sr = feat_loader.framessr2         
+    bounds = np.array([['0', '8.1', 'm']])
+    sr = feat_loader.framessr2
     music_bounds = feat_loader.get_music_idx_from_bounds(bounds, sr=sr)
     music_bounds_true = np.array([0])
     assert np.array_equal(music_bounds, music_bounds_true)
@@ -47,10 +48,11 @@
               ['13.5', '5.0', 'm']])
     sr = feat_loader.framessr2
     music_bounds = feat_loader.get_music_idx_from_bounds(bounds, sr=sr)
-    half_win_sec = 4.0  # assume 8-second window
-    music_bounds_true = np.concatenate([np.arange(np.round(sr * (10.5 - half_win_sec)), dtype=int),
-                                        np.arange(np.round(sr * (13.5 - half_win_sec)), 
-                                            np.round(sr * (18.5 - half_win_sec)), dtype=int)])
+    #half_win_sec = 4.0  # assume 8-second window
+    win_sec = 8.0  # assume 8-second window
+    music_bounds_true = np.concatenate([np.arange(np.round(sr * (10.5 - win_sec)), dtype=int),
+                                        np.arange(np.round(sr * 13.5), 
+                                            np.round(sr * (18.5 - win_sec)), dtype=int)])
     assert np.array_equal(music_bounds, music_bounds_true)
     
 
@@ -61,9 +63,10 @@
     sr = feat_loader.framessr2
     music_bounds = feat_loader.get_music_idx_from_bounds(bounds, sr=sr)
     half_win_sec = 4.0  # assume 8-second window
-    music_bounds_true = np.concatenate([np.arange(np.round(sr * (10.5 - half_win_sec)), dtype=int),
-                                        np.arange(np.round(sr * (11.5 - half_win_sec)), 
-                                            np.round(sr * (16.5 - half_win_sec)), dtype=int)])
+    win_sec = 8.0  # assume 8-second window
+    music_bounds_true = np.concatenate([np.arange(np.round(sr * (10.5 - win_sec)), dtype=int),
+                                        np.arange(np.round(sr * 11.5), 
+                                            np.round(sr * (16.5 - win_sec)), dtype=int)])
     assert np.array_equal(music_bounds, music_bounds_true)