Skip to content

Commit

Permalink
Add test for all_by_all_pairwise_similarity() in semsimian using cust…
Browse files Browse the repository at this point in the history
…om IC map (#801)

* Add test for all_by_all_pairwise_similarity() in semsimian using custom IC map

* Lint

* Assert > if/else

* Fix logic

---------

Co-authored-by: Justin Reese <[email protected]>
  • Loading branch information
justaddcoffee and Justin Reese authored Aug 21, 2024
1 parent 7602658 commit c93a9dc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_implementations/test_semsimian_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,28 @@ def test_similarity_with_custom_ic_map(self):
else:
raise ValueError(f"Did not get similarity for got {s} and {o}")

def test_all_by_all_similarity_with_custom_ic_map(self):
adapter = self.oi

adapter.custom_ic_map_path = TEST_IC_MAP.as_posix()

if not isinstance(adapter, SemanticSimilarityInterface):
raise AssertionError("SemanticSimilarityInterface not implemented")
entities = [VACUOLE, ENDOMEMBRANE_SYSTEM]

sim = (adapter.all_by_all_pairwise_similarity(entities, entities, predicates=self.predicates))

for s in sim:
self.assertIsNotNone(s)
if s.object_id == VACUOLE and s.subject_id == VACUOLE:
self.assertEqual(s.ancestor_information_content, 5.5)
if s.object_id == ENDOMEMBRANE_SYSTEM and s.subject_id == ENDOMEMBRANE_SYSTEM:
self.assertEqual(s.ancestor_information_content, 6.0)
if s.object_id == VACUOLE and s.subject_id == ENDOMEMBRANE_SYSTEM:
self.assertEqual(s.ancestor_information_content, 0)
else:
pass

def test_semsimian_object_cache(self):
start_time = timeit.default_timer()
_ = list(
Expand Down

0 comments on commit c93a9dc

Please sign in to comment.