Skip to content

Commit 9666ca5

Browse files
committed
Finish task iterator (first version)
1 parent bd85675 commit 9666ca5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

decyclify/node_iterators.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _next_nodes(self):
125125

126126
def _remove_nodes(self, nodes):
127127
for (key, intraiteration_node) in enumerate(self.intraiteration_nodes):
128-
for node in intraiteration_node:
128+
for node in intraiteration_node.copy():
129129
if node in nodes:
130130
intraiteration_node.remove(node)
131131
self.current_nodes.remove(node)
@@ -170,7 +170,7 @@ def _pop_next_interiteration(self, new_nodes_in_this_cycle):
170170
# returned, so we are good to return this downstream dependency
171171
if interiteration_trigger_node not in self.previous.current_nodes:
172172
nodes.append(next_intraiteration_node)
173-
self._remove_nodes([next_intraiteration_node])
173+
self._remove_nodes([node])
174174
return nodes
175175

176176

@@ -221,7 +221,7 @@ def __next__(self):
221221

222222
# collect tasks/nodes ready to execute in each cycle
223223
new_nodes_in_this_cycle = []
224-
for cycle in self.cycles:
224+
for cycle in self.cycles.copy():
225225
try:
226226
new_nodes_in_this_cycle.extend(cycle.iterate(new_nodes_in_this_cycle))
227227
except RemoveCycle:

tests/test_node_iterators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_tasks_iterator(sample_graph):
6363

6464
iterator = TasksIterator(graph, cycles_removed, cycles=2)
6565

66-
expected = [['a.0'], ['b.0', 'e.0', 'a.1'], ['c.0', 'b.1'], ['d.0', 'c.1'], ['d.1']]
66+
expected = [['a.0'], ['b.0', 'e.0', 'a.1'], ['c.0', 'b.1', 'e.1'], ['d.0', 'c.1'], ['d.1']]
6767
iterated = []
6868

6969
for index, node in enumerate(iterator):

0 commit comments

Comments
 (0)