From: Paul Brossier Date: Tue, 5 Mar 2013 03:58:05 +0000 (-0500) Subject: tests/: array_from_file to look for file in tests/ X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a4cc8e5d1443807ed8afb91b90349282cbbb14ce;p=aubio.git tests/: array_from_file to look for file in tests/ --- diff --git a/python/tests/test_filter.py b/python/tests/test_filter.py index 8e24bad3..da4ef895 100755 --- a/python/tests/test_filter.py +++ b/python/tests/test_filter.py @@ -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): diff --git a/python/tests/test_filterbank.py b/python/tests/test_filterbank.py index 3fd64fd9..02ae0f3e 100755 --- a/python/tests/test_filterbank.py +++ b/python/tests/test_filterbank.py @@ -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 index 00000000..28c076e1 --- /dev/null +++ b/python/tests/utils.py @@ -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) +