diff --git a/tests/test_lanczos.py b/tests/test_lanczos.py index fcfa818..b139249 100644 --- a/tests/test_lanczos.py +++ b/tests/test_lanczos.py @@ -8,8 +8,8 @@ ## Add the test directory to the sys path import sys import primate -ind = [i for i, c in enumerate(primate.__file__) if c == '/'][-3] -sys.path.insert(0, primate.__file__[:ind] + '/tests') +rel_dir = primate.__file__[:(primate.__file__.find('primate') + 7)] +sys.path.insert(0, rel_dir + '/tests') def test_basic(): from primate.diagonalize import lanczos diff --git a/tests/test_random.py b/tests/test_random.py index d4234e0..7c95d23 100644 --- a/tests/test_random.py +++ b/tests/test_random.py @@ -6,8 +6,8 @@ ## Add the test directory to the sys path import sys import primate -ind = [i for i, c in enumerate(primate.__file__) if c == '/'][-3] -sys.path.insert(0, primate.__file__[:ind] + '/tests') +rel_dir = primate.__file__[:(primate.__file__.find('primate') + 7)] +sys.path.insert(0, rel_dir + '/tests') def test_seeding(): s1 = random.rademacher(250, seed = -1) diff --git a/tests/test_slq.py b/tests/test_slq.py index adcbb4f..7cb543b 100644 --- a/tests/test_slq.py +++ b/tests/test_slq.py @@ -8,8 +8,8 @@ ## Add the test directory to the sys path import sys import primate -ind = [i for i, c in enumerate(primate.__file__) if c == '/'][-3] -sys.path.insert(0, primate.__file__[:ind] + '/tests') +rel_dir = primate.__file__[:(primate.__file__.find('primate') + 7)] +sys.path.insert(0, rel_dir + '/tests') def test_stochastic_quadrature(): from primate.diagonalize import _lanczos diff --git a/tests/test_stats.py b/tests/test_stats.py index 564e147..6481b75 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -7,8 +7,8 @@ ## Add the test directory to the sys path import sys import primate -ind = [i for i, c in enumerate(primate.__file__) if c == '/'][-3] -sys.path.insert(0, primate.__file__[:ind] + '/tests') +rel_dir = primate.__file__[:(primate.__file__.find('primate') + 7)] +sys.path.insert(0, rel_dir + '/tests') def test_incremental_est(): np.random.seed(1234)