From a4cc8e5d1443807ed8afb91b90349282cbbb14ce Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 4 Mar 2013 22:58:05 -0500 Subject: [PATCH] tests/: array_from_file to look for file in tests/ --- python/tests/test_filter.py | 5 +---- python/tests/test_filterbank.py | 5 +---- python/tests/utils.py | 9 +++++++++ 3 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 python/tests/utils.py 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) + -- 2.26.2