Skip to content

Commit fd96b81

Browse files
committed
Moved cache_filename reference to top-level for import elsewhere
1 parent 958f8bd commit fd96b81

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/strategies/test_strategies.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from ..context import skip_if_no_bayesopt_botorch, skip_if_no_bayesopt_gpytorch, skip_if_no_pyatf
1212

1313

14+
cache_filename = Path(__file__).parent / "test_cache_file.json"
15+
1416
@pytest.fixture
1517
def vector_add():
1618
kernel_string = """
@@ -53,7 +55,6 @@ def vector_add():
5355
strategies.append(s)
5456
@pytest.mark.parametrize('strategy', strategies)
5557
def test_strategies(vector_add, strategy):
56-
cache_filename = Path(__file__).parent / "test_cache_file.json"
5758
options = dict(popsize=5, neighbor='adjacent')
5859

5960
print(f"testing {strategy}")
@@ -69,18 +70,19 @@ def test_strategies(vector_add, strategy):
6970
restrictions = ["test_string == 'alg_2'", "test_bool == True", "test_mixed == 2.45"]
7071

7172
# pyATF can't handle non-number tune parameters, so we filter them out
73+
cache_filename_local = cache_filename
7274
if strategy == "pyatf_strategies":
7375
tune_params = {
7476
"block_size_x": [128 + 64 * i for i in range(15)]
7577
}
7678
restrictions = []
77-
cache_filename = cache_filename.parent.parent / "test_cache_file.json"
79+
cache_filename_local = cache_filename_local.parent.parent / "test_cache_file.json"
7880
vector_add[-1] = tune_params
7981

8082
# run the tuning in simulation mode
81-
assert cache_filename.exists()
83+
assert cache_filename_local.exists()
8284
results, _ = kernel_tuner.tune_kernel(*vector_add, restrictions=restrictions, strategy=strategy, strategy_options=filter_options,
83-
verbose=False, cache=cache_filename, simulation_mode=True)
85+
verbose=False, cache=cache_filename_local, simulation_mode=True)
8486

8587
assert len(results) > 0
8688

0 commit comments

Comments
 (0)