Mercurial > hg > plosone_underreview
diff 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 |
line wrap: on
line diff
--- a/tests/test_load_features.py Mon Sep 11 14:53:13 2017 +0100 +++ b/tests/test_load_features.py Mon Sep 11 18:23:14 2017 +0100 @@ -67,3 +67,28 @@ assert np.array_equal(music_bounds, music_bounds_true) +def test_average_local_frames(): + frames = np.array([[0, 0.5, 1], [1, 1, 1]]) + aveframes = feat_loader.average_local_frames(frames) + aveframes_true = np.array([[0.5], [1]]) + assert np.array_equal(aveframes, aveframes_true) + + +def test_average_local_frames_multiple_frames(): + frames1 = np.concatenate([np.repeat(0.5, feat_loader.hop2), np.repeat(0, feat_loader.win2)]) + frames2 = np.concatenate([np.repeat(1.5, feat_loader.hop2), np.repeat(1, feat_loader.win2)]) + frames = np.vstack([frames1, frames2]) + aveframes = feat_loader.average_local_frames(frames) + aveframes_true = np.array([[0.5, 0], [1.5, 1]]) + # test only the second frame which contains values 0 or values 1 for all 8-second frame entries + assert np.array_equal(aveframes[:, 1], aveframes_true[:, 1]) + + +def test_average_local_frames_std(): + frames1 = np.concatenate([np.repeat(0.5, feat_loader.hop2), np.repeat(0, feat_loader.win2)]) + frames2 = np.concatenate([np.repeat(1.5, feat_loader.hop2), np.repeat(1, feat_loader.win2)]) + frames = np.vstack([frames1, frames2]) + aveframes = feat_loader.average_local_frames(frames, getstd=True) + aveframes_true = np.array([[0.5, 0], [1.5, 1], [0.1, 0], [0.1, 0]]) + # test only the second frame which contains values 0 or values 1 for all 8-second frame entries + assert np.array_equal(aveframes[:, 1], aveframes_true[:, 1])