Skip to content

Commit

Permalink
feat: adding option to reset the ResolutionProver
Browse files Browse the repository at this point in the history
  • Loading branch information
chanind committed Dec 8, 2022
1 parent 5aca388 commit 8649c91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensor_theorem_prover/prover/ResolutionProver.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ def prove_all(
def purge_similarity_cache(self) -> None:
self.similarity_cache.clear()

def reset(self) -> None:
"""Clear all knowledge from the prover and wipe the similarity cache"""
self.base_knowledge = []
self.purge_similarity_cache()

def _prove_all_recursive(
self,
goal: CNFDisjunction,
Expand Down
8 changes: 8 additions & 0 deletions tests/prover/test_ResolutionProver.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,11 @@ def test_purge_similarity_cache() -> None:
prover.similarity_cache = {(1, 2): 0.5}
prover.purge_similarity_cache()
assert prover.similarity_cache == {}


def test_reset() -> None:
prover = ResolutionProver(knowledge=[parent_of(homer, bart)])
prover.similarity_cache = {(1, 2): 0.5}
prover.reset()
assert prover.similarity_cache == {}
assert prover.base_knowledge == []

0 comments on commit 8649c91

Please sign in to comment.