Skip to content

Commit

Permalink
fix(common): intermediate result removal fails if there are duplicate…
Browse files Browse the repository at this point in the history
…d dependencies
  • Loading branch information
kszucs committed Feb 12, 2024
1 parent e3f2217 commit e3e17db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ibis/common/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def map_clear(

# remove the results belonging to the dependencies if they are not
# needed by other nodes during the rest of the traversal
for dependency in dependencies:
for dependency in set(dependencies):
dependents[dependency].remove(node)
if not dependents[dependency]:
del results[dependency]
Expand Down
10 changes: 7 additions & 3 deletions ibis/common/tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ def test_node_find_topmost_dont_traverse_the_same_node_twice():


def test_map_clear():
Z = MyNode(name="Z", children=[A])
Z = MyNode(name="Z", children=[A, A])
Y = MyNode(name="Y", children=[A])
X = MyNode(name="X", children=[Z, Y])
result_sequence = {}

def record_result_keys(node, results, **kwargs):
Expand All @@ -445,7 +447,9 @@ def record_result_keys(node, results, **kwargs):
B: (C, D, E),
A: (C, B),
Z: (A,),
Y: (A, Z),
X: (Z, Y),
}
result = Z.map_clear(record_result_keys)
assert result == Z
result = X.map_clear(record_result_keys)
assert result == X
assert result_sequence == expected_result_sequence

0 comments on commit e3e17db

Please sign in to comment.