Skip to content

Commit 3e034f7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e2883d5 commit 3e034f7

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

fix_minimal.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Fix all remaining issues in the graph algorithms PR.
44
Run from repo root.
55
"""
6+
67
from pathlib import Path
78

89

@@ -11,7 +12,9 @@ def fix_chinese_postman():
1112
text = p.read_text()
1213

1314
# Only add -> None to __init__
14-
text = text.replace('def __init__(self, n: int):', 'def __init__(self, n: int) -> None:')
15+
text = text.replace(
16+
"def __init__(self, n: int):", "def __init__(self, n: int) -> None:"
17+
)
1518

1619
p.write_text(text)
1720
print("fixed chinese_postman.py")
@@ -21,7 +24,9 @@ def fix_ford_fulkerson():
2124
p = Path("graphs/ford_fulkerson.py")
2225
text = p.read_text()
2326

24-
text = text.replace('def __init__(self, n: int):', 'def __init__(self, n: int) -> None:')
27+
text = text.replace(
28+
"def __init__(self, n: int):", "def __init__(self, n: int) -> None:"
29+
)
2530

2631
p.write_text(text)
2732
print("fixed ford_fulkerson.py")
@@ -31,7 +36,7 @@ def fix_floyd_warshall():
3136
p = Path("graphs/floyd_warshall.py")
3237
text = p.read_text()
3338

34-
text = text.replace(' def benchmark():', ' def benchmark() -> None:')
39+
text = text.replace(" def benchmark():", " def benchmark() -> None:")
3540

3641
p.write_text(text)
3742
print("fixed floyd_warshall.py")
@@ -41,8 +46,8 @@ def fix_two_sat():
4146
p = Path("graphs/two_sat.py")
4247
text = p.read_text()
4348

44-
text = text.replace('def dfs1(u: int):', 'def dfs1(u: int) -> None:')
45-
text = text.replace('def dfs2(u: int):', 'def dfs2(u: int) -> None:')
49+
text = text.replace("def dfs1(u: int):", "def dfs1(u: int) -> None:")
50+
text = text.replace("def dfs2(u: int):", "def dfs2(u: int) -> None:")
4651

4752
p.write_text(text)
4853
print("fixed two_sat.py")
@@ -53,12 +58,12 @@ def fix_test_graph_algorithms():
5358
text = p.read_text()
5459

5560
# Fix johnson test expectation
56-
text = text.replace('assert dist[0][4] == -1', 'assert dist[0][4] == 0')
61+
text = text.replace("assert dist[0][4] == -1", "assert dist[0][4] == 0")
5762

5863
# Fix codespell: mis -> independent_set
59-
text = text.replace('mis = ', 'independent_set = ')
60-
text = text.replace('(mis)', '(independent_set)')
61-
text = text.replace('mis.', 'independent_set.')
64+
text = text.replace("mis = ", "independent_set = ")
65+
text = text.replace("(mis)", "(independent_set)")
66+
text = text.replace("mis.", "independent_set.")
6267

6368
p.write_text(text)
6469
print("fixed test_graph_algorithms.py")
@@ -71,4 +76,4 @@ def fix_test_graph_algorithms():
7176
fix_floyd_warshall()
7277
fix_two_sat()
7378
fix_test_graph_algorithms()
74-
print("\nDone! Now run tests and ruff.")
79+
print("\nDone! Now run tests and ruff.")

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)