Skip to content

Commit f113736

Browse files
🎨 pre-commit fixes
1 parent 4a7f884 commit f113736

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/scripts/running_utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def run_clustering_con(g, inputf, outputf, k, costf):
7070
if "---" in line:
7171
lines = True
7272
elif lines:
73-
k = [int(s) for s in line.split() if s.isdigit()][0]
73+
k = next(int(s) for s in line.split() if s.isdigit())
7474

7575
nodes_by_color[k].append(counter)
7676
color_by_node[counter] = k
@@ -85,7 +85,7 @@ def run_clustering_con(g, inputf, outputf, k, costf):
8585

8686
for n in range(len(list(g.nodes))):
8787
if len(list(g.neighbors(n))) == 1:
88-
g.nodes[n]["c"] = g.nodes[list(g.neighbors(n))[0]]["c"]
88+
g.nodes[n]["c"] = g.nodes[next(iter(g.neighbors(n)))]["c"]
8989

9090
new_col_by_node = []
9191
for i in g.nodes(data=True):
@@ -166,7 +166,7 @@ def run_clustering_all(g, inputf, outputf, k, costf):
166166
if "---" in line:
167167
lines = True
168168
elif lines:
169-
k = [int(s) for s in line.split() if s.isdigit()][0]
169+
k = next(int(s) for s in line.split() if s.isdigit())
170170

171171
nodes_by_color[k].append(counter)
172172
color_by_node[counter] = k
@@ -180,7 +180,7 @@ def run_clustering_all(g, inputf, outputf, k, costf):
180180
# We don't need to fix terminal edges anymore, but we know it's a split qubit in that case, better not messing up
181181
for n in range(len(list(g.nodes))):
182182
if len(list(g.neighbors(n))) == 1:
183-
g.nodes[n]["c"] = g.nodes[list(g.neighbors(n))[0]]["c"]
183+
g.nodes[n]["c"] = g.nodes[next(iter(g.neighbors(n)))]["c"]
184184

185185
new_col_by_node = []
186186
for i in g.nodes(data=True):

0 commit comments

Comments
 (0)