comparison tests/test_load_features.py @ 8:0f3eba42b425 branch-tests

added notebooks and utils
author Maria Panteli <m.x.panteli@gmail.com>
date Mon, 11 Sep 2017 18:23:14 +0100
parents a35bd818d8e9
children 115774aff442
comparison
equal deleted inserted replaced
7:46b2c713cc73 8:0f3eba42b425
65 np.arange(np.round(sr * (11.5 - half_win_sec)), 65 np.arange(np.round(sr * (11.5 - half_win_sec)),
66 np.round(sr * (16.5 - half_win_sec)), dtype=int)]) 66 np.round(sr * (16.5 - half_win_sec)), dtype=int)])
67 assert np.array_equal(music_bounds, music_bounds_true) 67 assert np.array_equal(music_bounds, music_bounds_true)
68 68
69 69
70 def test_average_local_frames():
71 frames = np.array([[0, 0.5, 1], [1, 1, 1]])
72 aveframes = feat_loader.average_local_frames(frames)
73 aveframes_true = np.array([[0.5], [1]])
74 assert np.array_equal(aveframes, aveframes_true)
75
76
77 def test_average_local_frames_multiple_frames():
78 frames1 = np.concatenate([np.repeat(0.5, feat_loader.hop2), np.repeat(0, feat_loader.win2)])
79 frames2 = np.concatenate([np.repeat(1.5, feat_loader.hop2), np.repeat(1, feat_loader.win2)])
80 frames = np.vstack([frames1, frames2])
81 aveframes = feat_loader.average_local_frames(frames)
82 aveframes_true = np.array([[0.5, 0], [1.5, 1]])
83 # test only the second frame which contains values 0 or values 1 for all 8-second frame entries
84 assert np.array_equal(aveframes[:, 1], aveframes_true[:, 1])
85
86
87 def test_average_local_frames_std():
88 frames1 = np.concatenate([np.repeat(0.5, feat_loader.hop2), np.repeat(0, feat_loader.win2)])
89 frames2 = np.concatenate([np.repeat(1.5, feat_loader.hop2), np.repeat(1, feat_loader.win2)])
90 frames = np.vstack([frames1, frames2])
91 aveframes = feat_loader.average_local_frames(frames, getstd=True)
92 aveframes_true = np.array([[0.5, 0], [1.5, 1], [0.1, 0], [0.1, 0]])
93 # test only the second frame which contains values 0 or values 1 for all 8-second frame entries
94 assert np.array_equal(aveframes[:, 1], aveframes_true[:, 1])