Skip to content

Commit

Permalink
Fixes an edge case where levenshtein bound calculation can be incorre…
Browse files Browse the repository at this point in the history
…ct for single element lists #32
  • Loading branch information
ESultanik committed Sep 15, 2021
1 parent 56904ff commit 6551c59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions graphtage/graphtage.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ def edits(self, node: TreeNode) -> Edit:
if isinstance(node, ListNode):
if self._children == node._children:
return Match(self, node, 0)
elif len(self._children) == 1 == len(node._children):
return self._children[0].edits(node._children[0])
elif not self.allow_list_edits or (len(self._children) == len(node._children) and (
not self.allow_list_edits_when_same_length or len(self._children) == 1
)):
Expand Down
5 changes: 4 additions & 1 deletion graphtage/sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ def is_complete(self) -> bool:
def tighten_bounds(self) -> bool:
for edit in self._sub_edits:
prev_bounds = edit.bounds()
if str(prev_bounds) == "[29, 84]":
breakpoint()
if edit.tighten_bounds():
new_bounds = edit.bounds()
if prev_bounds.lower_bound > new_bounds.lower_bound or prev_bounds.upper_bound < new_bounds.upper_bound:
log.warning(f"The most recent call to `tighten_bounds()` on edit {edit} tightened its bounds from {prev_bounds} to {new_bounds}")
log.warning(f"The most recent call to `tighten_bounds()` on edit {edit} tightened its bounds from "
f"{prev_bounds} to {new_bounds}")
return True
return False

Expand Down

0 comments on commit 6551c59

Please sign in to comment.