From f19232e1c36cbce536269144a26c48a20813cafa Mon Sep 17 00:00:00 2001 From: peekxc Date: Mon, 4 Dec 2023 17:05:01 -0500 Subject: [PATCH] Fixed relative pathing issues for tests --- tests/test_lanczos.py | 4 ++-- tests/test_random.py | 4 ++-- tests/test_slq.py | 4 ++-- tests/test_stats.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) 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)