Skip to content

Commit

Permalink
Implement ContextCache.empty() and fix bug in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrrizzi committed Feb 14, 2017
1 parent 94122cd commit f421b45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openmmtools/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ def time_to_live(self):
def time_to_live(self, new_time_to_live):
self._lru.time_to_live = new_time_to_live

def empty(self):
"""Clear up cache and remove all Contexts."""
self._lru.empty()

def get_context(self, thermodynamic_state, integrator):
"""Return a context in the given thermodynamic state.
Expand Down
1 change: 1 addition & 0 deletions openmmtools/tests/test_mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def test_context_cache():
thermodynamic_state = ThermodynamicState(testsystem.system, 300*unit.kelvin)

# By default the global context cache is used.
cache.global_context_cache.empty() # Clear cache from previous tests.
move = SequenceMove([LangevinDynamicsMove(n_steps=5), GHMCMove(n_steps=5)])
move.apply(thermodynamic_state, sampler_state)
assert len(cache.global_context_cache) == 2
Expand Down

0 comments on commit f421b45

Please sign in to comment.