Skip to content

Commit

Permalink
Document where the cache fixture is used
Browse files Browse the repository at this point in the history
  • Loading branch information
AnesBenmerzoug committed Oct 29, 2023
1 parent 7a409a4 commit 88a0319
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ def pytest_addoption(parser):
def cache(request: "FixtureRequest") -> CloudPickleCache:
"""Return a cache object that can persist state between testing sessions.
```pycon
cache.get(key, default)
cache.set(key, value)
```
Keys must be ``/`` separated strings, where the first part is usually the
name of your plugin or application to avoid clashes with other cache users.
Expand Down
2 changes: 2 additions & 0 deletions tests/value/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def analytic_banzhaf(dummy_utility):

@pytest.fixture(scope="function")
def linear_shapley(cache, linear_dataset, scorer, n_jobs):
"""This fixture makes use of the cache fixture to avoid recomputing
exact shapley values for each test run."""
args_hash = cache.hash_arguments(linear_dataset, scorer, n_jobs)
u_cache_key = f"linear_shapley_u_{args_hash}"
exact_values_cache_key = f"linear_shapley_exact_values_{args_hash}"
Expand Down

0 comments on commit 88a0319

Please sign in to comment.