Skip to content

Commit

Permalink
added test for inverse walks to test_random
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesVandewiele committed Mar 24, 2022
1 parent 67e5f2a commit 3f234c0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/walkers/test_random.py
Expand Up @@ -101,7 +101,7 @@ def test_extract(
walker = RandomWalker(
max_depth, max_walks, with_reverse=with_reverse, random_state=42
)
walks = walker._extract(kg, Vertex(root))[root]
walks = walker.extract(kg, [root])[0]
if max_walks is not None:
if with_reverse:
assert len(walks) <= max_walks * max_walks
Expand All @@ -116,3 +116,11 @@ def test_extract(
assert len(walk) <= (max_depth * 2) + 1
else:
assert len(walk) <= ((max_depth * 2) + 1) * 2

def test_inverse_extract(self, setup):
walker = RandomWalker(1, None, with_reverse=True, random_state=42)
walks = walker.extract(KG_LOOP, [f"{URL}#Bob", f"{URL}#Alice"])
assert any(
walk[0] == f"{URL}#Alice" and walk[2] == f"{URL}#Bob"
for walk in walks[0] + walks[1]
)

0 comments on commit 3f234c0

Please sign in to comment.