diff tests/test_PitchBihist.py @ 85:9b2beffa5fdd branch-tests

test updates
author Maria Panteli <m.x.panteli@gmail.com>
date Tue, 26 Sep 2017 21:19:19 +0100
parents 0e70021f251e
children
line wrap: on
line diff
--- a/tests/test_PitchBihist.py	Tue Sep 26 20:42:44 2017 +0100
+++ b/tests/test_PitchBihist.py	Tue Sep 26 21:19:19 2017 +0100
@@ -8,12 +8,14 @@
 import pytest
 
 import numpy as np
+import os
 
 import scripts.PitchBihist as PitchBihist
 
 
 pbi = PitchBihist.PitchBihist()
-
+TEST_MELODIA_FILE = os.path.join(os.path.dirname(__file__), os.path.pardir, 
+                                 'data', 'sample_dataset', 'Melodia', 'mel_1_2_1.csv')
 
 def test_hz_to_cents():
     freq_Hz = np.array([32.703, 65.406, 55, 110])
@@ -30,7 +32,7 @@
 
 
 def test_get_melody_from_file():
-    melodia_file = 'data/sample_dataset/Melodia/mel_1_2_1.csv'
+    melodia_file = TEST_MELODIA_FILE
     melody = pbi.get_melody_from_file(melodia_file)
     assert len(melody) < 12. * pbi.melody_sr
 
@@ -56,13 +58,13 @@
 
 
 def test_bihist_from_melodia():
-    melodia_file = 'data/sample_dataset/Melodia/mel_1_2_1.csv'
+    melodia_file = TEST_MELODIA_FILE
     bihist = pbi.bihist_from_melodia(melodia_file, secondframedecomp=False)
     assert bihist.shape == (60, 60)
 
 
 def test_bihist_from_melodia_n_frames():
-    melodia_file = 'data/sample_dataset/Melodia/mel_1_2_1.csv'
+    melodia_file = TEST_MELODIA_FILE
     bihist = pbi.bihist_from_melodia(melodia_file, secondframedecomp=True)
     dur_sec = 11.5  # duration of first file in metadata.csv is > 11 seconds
     n_frames_true = np.round((dur_sec - pbi.win2sec) * 2)  # for .5 sec hop size