tests/: array_from_file to look for file in tests/
authorPaul Brossier <piem@piem.org>
Tue, 5 Mar 2013 03:58:05 +0000 (22:58 -0500)
committerPaul Brossier <piem@piem.org>
Tue, 5 Mar 2013 03:58:05 +0000 (22:58 -0500)
python/tests/test_filter.py
python/tests/test_filterbank.py
python/tests/utils.py [new file with mode: 0644]

index 8e24bad335af3d2e03b599aa0677ca3353dc0fe5..da4ef895aec2de08f8bbbcfb271e8555ff6f3fb8 100755 (executable)
@@ -3,10 +3,7 @@
 from numpy.testing import TestCase, assert_equal, assert_almost_equal
 from aubio import fvec, digital_filter
 from numpy import array
-
-def array_from_text_file(filename, dtype = 'float'):
-  return array([line.split() for line in open(filename).readlines()], 
-      dtype = dtype)
+from utils import array_from_text_file
 
 class aubio_filter_test_case(TestCase):
 
index 3fd64fd9a877c0fc7ed686ba83514e3a5181b34e..02ae0f3e2ebb30f83eef26cb04679576a6836274 100755 (executable)
@@ -6,10 +6,7 @@ from numpy import random
 from math import pi
 from numpy import array
 from aubio import cvec, filterbank
-
-def array_from_text_file(filename, dtype = 'float'):
-  return array([line.split() for line in open(filename).readlines()], 
-      dtype = dtype)
+from utils import array_from_text_file
 
 class aubio_filterbank_test_case(TestCase):
 
diff --git a/python/tests/utils.py b/python/tests/utils.py
new file mode 100644 (file)
index 0000000..28c076e
--- /dev/null
@@ -0,0 +1,9 @@
+#! /usr/bin/env python
+
+def array_from_text_file(filename, dtype = 'float'):
+  import os.path
+  from numpy import array
+  filename = os.path.join(os.path.dirname(__file__), filename)
+  return array([line.split() for line in open(filename).readlines()], 
+      dtype = dtype)
+