Skip to content

Commit 70b94f1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 22d5ba3 commit 70b94f1

2 files changed

Lines changed: 19 additions & 25 deletions

File tree

fix_ruff_errors.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def fix_floyd_warshall():
1111
p = Path("graphs/floyd_warshall.py")
1212
text = p.read_text()
1313
text = text.replace(
14-
'current = next_node[current][end] # type: ignore',
15-
'current = next_node[current][end] # type: ignore[assignment]'
14+
"current = next_node[current][end] # type: ignore",
15+
"current = next_node[current][end] # type: ignore[assignment]",
1616
)
1717
p.write_text(text)
1818
print("fixed graphs/floyd_warshall.py")
@@ -22,8 +22,7 @@ def fix_ford_fulkerson():
2222
p = Path("graphs/ford_fulkerson.py")
2323
text = p.read_text()
2424
text = text.replace(
25-
'u = parent[s] # type: ignore',
26-
'u = parent[s] # type: ignore[assignment]'
25+
"u = parent[s] # type: ignore", "u = parent[s] # type: ignore[assignment]"
2726
)
2827
p.write_text(text)
2928
print("fixed graphs/ford_fulkerson.py")
@@ -54,15 +53,15 @@ def fix_hopcroft_karp():
5453
text = text.replace(
5554
'self.dist[u] = float("inf") # type: ignore',
5655
'self.dist[u] = float("inf") # type: ignore[assignment]',
57-
1
56+
1,
5857
)
5958
text = text.replace(
6059
'if pair_v is not None and self.dist[pair_v] == float("inf"): # type: ignore',
61-
'if pair_v is not None and self.dist[pair_v] == float("inf"): # type: ignore[operator]'
60+
'if pair_v is not None and self.dist[pair_v] == float("inf"): # type: ignore[operator]',
6261
)
6362
text = text.replace(
6463
'self.dist[u] = float("inf") # type: ignore',
65-
'self.dist[u] = float("inf") # type: ignore[assignment]'
64+
'self.dist[u] = float("inf") # type: ignore[assignment]',
6665
)
6766

6867
old = """ if self.pair_u[u] is None:
@@ -90,25 +89,25 @@ def fix_max_bipartite_independent_set():
9089
text = p.read_text()
9190

9291
text = text.replace(
93-
'# Minimum vertex cover = (U - Z) \u222a (V \u2229 Z)',
94-
'# Minimum vertex cover = (U - Z) union (V intersect Z)'
92+
"# Minimum vertex cover = (U - Z) \u222a (V \u2229 Z)",
93+
"# Minimum vertex cover = (U - Z) union (V intersect Z)",
9594
)
9695
text = text.replace(
97-
'# Maximum independent set = Z \u222a (V - Z) = complement of min vertex cover',
98-
'# Maximum independent set = Z union (V - Z) = complement of min vertex cover'
96+
"# Maximum independent set = Z \u222a (V - Z) = complement of min vertex cover",
97+
"# Maximum independent set = Z union (V - Z) = complement of min vertex cover",
9998
)
10099
text = text.replace(
101100
'dist[u] = float("inf") # type: ignore',
102101
'dist[u] = float("inf") # type: ignore[assignment]',
103-
1
102+
1,
104103
)
105104
text = text.replace(
106105
'if pu is not None and dist[pu] == float("inf"): # type: ignore',
107-
'if pu is not None and dist[pu] == float("inf"): # type: ignore[operator]'
106+
'if pu is not None and dist[pu] == float("inf"): # type: ignore[operator]',
108107
)
109108
text = text.replace(
110109
'dist[u] = float("inf") # type: ignore',
111-
'dist[u] = float("inf") # type: ignore[assignment]'
110+
'dist[u] = float("inf") # type: ignore[assignment]',
112111
)
113112

114113
p.write_text(text)
@@ -119,8 +118,8 @@ def fix_push_relabel():
119118
p = Path("graphs/push_relabel.py")
120119
text = p.read_text()
121120

122-
old = 'v for v in range(n) if v != source and v != sink and self.excess[v] > 0'
123-
new = 'v for v in range(n) if v not in (source, sink) and self.excess[v] > 0'
121+
old = "v for v in range(n) if v != source and v != sink and self.excess[v] > 0"
122+
new = "v for v in range(n) if v not in (source, sink) and self.excess[v] > 0"
124123
text = text.replace(old, new)
125124

126125
old = """ if (
@@ -143,13 +142,10 @@ def fix_test_graph_algorithms():
143142
text = p.read_text()
144143

145144
text = text.replace(
146-
'dist, next_node = floyd_warshall(graph)',
147-
'_dist, next_node = floyd_warshall(graph)'
148-
)
149-
text = text.replace(
150-
'result = hk.max_matching()',
151-
'hk.max_matching()'
145+
"dist, next_node = floyd_warshall(graph)",
146+
"_dist, next_node = floyd_warshall(graph)",
152147
)
148+
text = text.replace("result = hk.max_matching()", "hk.max_matching()")
153149

154150
p.write_text(text)
155151
print("fixed graphs/tests/test_graph_algorithms.py")

graphs/push_relabel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ def max_flow(self, source: int, sink: int) -> int:
8181
self.excess[source] -= cap
8282

8383
# Process vertices with excess
84-
active = [
85-
v for v in range(n) if v not in (source, sink) and self.excess[v] > 0
86-
]
84+
active = [v for v in range(n) if v not in (source, sink) and self.excess[v] > 0]
8785

8886
while active:
8987
u = active.pop()

0 commit comments

Comments
 (0)