Mercurial > hg > plosone_underreview
diff tests/test_PitchBihist.py @ 37:2cc444441f42 branch-tests
refactor pitchbihist and introduce default melody_sr
| author | Maria Panteli |
|---|---|
| date | Thu, 14 Sep 2017 14:50:00 +0100 |
| parents | 3b67cd634b9a |
| children | 0e70021f251e |
line wrap: on
line diff
--- a/tests/test_PitchBihist.py Thu Sep 14 14:16:29 2017 +0100 +++ b/tests/test_PitchBihist.py Thu Sep 14 14:50:00 2017 +0100 @@ -32,7 +32,7 @@ def test_get_melody_from_file(): melodia_file = 'data/sample_dataset/Melodia/mel_1_2_1.csv' melody = pbi.get_melody_from_file(melodia_file) - assert len(melody) < 12. * pbi.chromasr + assert len(melody) < 12. * pbi.melody_sr def test_get_melody_matrix(): @@ -72,4 +72,11 @@ assert bihist[45, 0] > 0 and (np.sum(bihist) - bihist[45, 0]) == 0 - +def test_bihistogram_align(): + melody = np.concatenate([660 * np.ones(250), 440 * np.ones(500)]) + melody_matrix = pbi.get_melody_matrix(melody) + # bin of max magnitude = A = 45/60 + bihist = pbi.bihistogram(melody_matrix, align=True) + # bihist[20, 45] == 0 + # we shift up 45 so rows 20-45 and left 45 so cols 45-45 + assert bihist[20-45, 0] == 1
