Skip to content

STY: Apply ruff/flake8-simplify rules (SIM) #3676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 6, 2024
Prev Previous commit
Next Next commit
STY: Apply ruff/flake8-simplify rule SIM113
SIM113 Use `enumerate()` for index variable in `for` loop
  • Loading branch information
DimitriPapadopoulos committed Oct 6, 2024
commit 4b88c39cfa9a2d3ece03e1121b612ca35b917cce
4 changes: 1 addition & 3 deletions nipype/pipeline/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,13 +1709,11 @@ def topological_sort(graph, depth_first=False):
logger.debug("Performing depth first search")
nodes = []
groups = []
group = 0
G = nx.Graph()
G.add_nodes_from(graph.nodes())
G.add_edges_from(graph.edges())
components = nx.connected_components(G)
for desc in components:
group += 1
for group, desc in enumerate(components, start=1):
indices = [nodesort.index(node) for node in desc]
nodes.extend(
np.array(nodesort)[np.array(indices)[np.argsort(indices)]].tolist()
Expand Down