Skip to content

Commit

Permalink
fix(ir): fix bug where iterator was not remembering visited nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
glencoe committed Nov 14, 2024
1 parent 1cd2a35 commit 3da0dbc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions elasticai/creator/ir/graph_delegate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ def test_iterating_breadth_first_upwards():
)

actual = tuple(bfs_iter_up(g.get_predecessors, "5"))
assert set(actual[0:2]) == {"3", "6"}
assert (set(actual[2:4]) == {"1", "2"} and actual[4] == "4") or (
set(actual[3:5]) == {"1", "2"} and actual[2] == "4"
)
assert actual == ("3", "6", "1", "2", "4", "0")


def test_iterating_depth_first_preorder():
Expand Down
1 change: 1 addition & 0 deletions elasticai/creator/ir/graph_iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def bfs_iter_down(successors: NodeNeighbourFn, start: HashableT) -> Iterator[Has
for p in successors(current):
if p not in visited:
yield p
visited.add(p)
visit_next.append(p)
visited.add(current)

Expand Down

0 comments on commit 3da0dbc

Please sign in to comment.