Skip to content

Commit 8fc84ad

Browse files
committed
chore: format code
1 parent facd4fd commit 8fc84ad

File tree

17 files changed

+65
-104
lines changed

17 files changed

+65
-104
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Docstring style
3535
run: poetry run pydocstyle src/ssspx
3636
- name: Docstring coverage
37-
run: poetry run docstr-coverage src/ssspx --fail-under 90
37+
run: poetry run interrogate -q -c pyproject.toml
3838
- name: Type check
3939
run: poetry run mypy src/ssspx
4040
- name: Security scan

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ repos:
2525
rev: 6.0.1
2626
hooks:
2727
- id: isort
28-
files: ^(src|tests)/
28+
files: ^src/
2929
args: ["--profile", "black", "--line-length", "100"]
3030

3131
- repo: https://github.com/psf/black
3232
rev: 25.1.0
3333
hooks:
3434
- id: black
35-
files: ^(src|tests)/
35+
files: ^src/
3636
args: ["--line-length", "100"]
3737

3838
- repo: https://github.com/pycqa/flake8
3939
rev: 7.3.0
4040
hooks:
4141
- id: flake8
42-
files: ^(src|tests)/
42+
files: ^src/
4343
additional_dependencies:
4444
- flake8-docstrings
4545
args: ["--max-line-length=100", "--extend-ignore=E203,W503,D401"]

mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ strict = True
44
warn_unused_ignores = True
55
warn_return_any = True
66
warn_unused_configs = True
7+
exclude = (?x)(
8+
^tests/
9+
)
710

811
[mypy-numpy.*]
912
ignore_missing_imports = True

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ changelog_file = "CHANGELOG.md"
7777
[tool.flake8]
7878
max-line-length = 100
7979
extend-ignore = ["E203", "W503", "D401"]
80+
exclude = [".git", "__pycache__", "build", "dist", ".eggs", "*.pyc", "*.pyo", "tests"]
8081

8182
[tool.pydocstyle]
8283
convention = "google"
@@ -110,3 +111,23 @@ omit = [
110111

111112
[tool.coverage.report]
112113
skip_empty = true
114+
115+
[tool.interrogate]
116+
ignore-init-method = true
117+
ignore-init-module = false
118+
ignore-magic = false
119+
ignore-semiprivate = false
120+
ignore-private = false
121+
ignore-property-decorators = false
122+
ignore-module = true
123+
ignore-nested-functions = false
124+
ignore-nested-classes = true
125+
ignore-setters = false
126+
fail-under = 90
127+
exclude = ["setup.py", "docs", "build", "tests"]
128+
ignore-regex = ["^get$", "^mock_.*", ".*BaseClass.*"]
129+
verbose = 0
130+
quiet = false
131+
whitelist-regex = []
132+
color = true
133+
omit-covered-files = false

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
22
max-line-length = 100
33
extend-ignore = E203,W503,D401
4-
exclude = .git,__pycache__,build,dist,.eggs,*.pyc,*.pyo
4+
exclude = .git,__pycache__,build,dist,.eggs,*.pyc,*.pyo,tests

src/ssspx/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
from __future__ import annotations
44

55
from .dijkstra import dijkstra_reference
6-
from .exceptions import (AlgorithmError, ConfigError, GraphError,
7-
GraphFormatError, InputError, NotSupportedError)
6+
from .exceptions import (
7+
AlgorithmError,
8+
ConfigError,
9+
GraphError,
10+
GraphFormatError,
11+
InputError,
12+
NotSupportedError,
13+
)
814
from .graph import Graph
915

1016
try: # pragma: no cover

src/ssspx/bench.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,15 @@ def main(argv: List[str] | None = None) -> None:
117117
argv: Optional argument list for testing.
118118
"""
119119
parser = argparse.ArgumentParser(description=__doc__)
120-
parser.add_argument(
121-
"--trials", type=int, default=1, help="Number of trials per configuration"
122-
)
120+
parser.add_argument("--trials", type=int, default=1, help="Number of trials per configuration")
123121
parser.add_argument(
124122
"--sizes",
125123
nargs="+",
126124
default=["10,20", "20,40"],
127125
help="Size pairs as n,m (e.g. 1000,5000). Defaults to a small demo.",
128126
)
129-
parser.add_argument(
130-
"--seed-base", type=int, default=0, help="Base seed for random graphs"
131-
)
132-
parser.add_argument(
133-
"--out-csv", type=Path, help="Optional path to write per-trial CSV data"
134-
)
127+
parser.add_argument("--seed-base", type=int, default=0, help="Base seed for random graphs")
128+
parser.add_argument("--out-csv", type=Path, help="Optional path to write per-trial CSV data")
135129
parser.add_argument(
136130
"--mem",
137131
action="store_true",

src/ssspx/cli.py

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from pathlib import Path
1111
from typing import List, Optional, Tuple
1212

13-
from .exceptions import (ConfigError, GraphFormatError, InputError,
14-
NotSupportedError, SSSPXError)
13+
from .exceptions import ConfigError, GraphFormatError, InputError, NotSupportedError, SSSPXError
1514
from .export import export_dag_graphml, export_dag_json
1615
from .graph import Graph
1716
from .io import read_graph
@@ -105,26 +104,16 @@ def main(argv: Optional[List[str]] = None) -> int:
105104
default=None,
106105
help="Comma-separated list of source vertex ids",
107106
)
108-
p.add_argument(
109-
"--target", type=int, default=None, help="Target vertex id for path output"
110-
)
107+
p.add_argument("--target", type=int, default=None, help="Target vertex id for path output")
111108

112-
p.add_argument(
113-
"--no-transform", action="store_true", help="Disable outdegree transform"
114-
)
115-
p.add_argument(
116-
"--target-outdeg", type=int, default=4, help="Outdegree cap when transforming"
117-
)
109+
p.add_argument("--no-transform", action="store_true", help="Disable outdegree transform")
110+
p.add_argument("--target-outdeg", type=int, default=4, help="Outdegree cap when transforming")
118111
p.add_argument("--frontier", choices=["block", "heap"], default="block")
119112

120113
# Profiling + export
121114
p.add_argument("--profile", action="store_true", help="Enable cProfile")
122-
p.add_argument(
123-
"--profile-out", type=str, default=None, help="Dump .prof file to this path"
124-
)
125-
p.add_argument(
126-
"--export-json", type=str, default=None, help="Write shortest-path DAG as JSON"
127-
)
115+
p.add_argument("--profile-out", type=str, default=None, help="Dump .prof file to this path")
116+
p.add_argument("--export-json", type=str, default=None, help="Write shortest-path DAG as JSON")
128117
p.add_argument(
129118
"--export-graphml",
130119
type=str,
@@ -160,9 +149,7 @@ def main(argv: Optional[List[str]] = None) -> int:
160149
)
161150

162151
stream = sys.stdout if args.log_json else sys.stderr
163-
level = (
164-
"info" if args.log_json and args.log_level == "warning" else args.log_level
165-
)
152+
level = "info" if args.log_json and args.log_level == "warning" else args.log_level
166153
logger = StdLogger(level=level, json_fmt=args.log_json, stream=stream)
167154

168155
if args.sources is not None:
@@ -189,15 +176,11 @@ def main(argv: Optional[List[str]] = None) -> int:
189176
t0 = time.perf_counter()
190177
if args.profile:
191178
with ProfileSession(dump_path=args.profile_out) as prof:
192-
solver = SSSPSolver(
193-
G, sources[0], config=cfg, logger=logger, sources=sources
194-
)
179+
solver = SSSPSolver(G, sources[0], config=cfg, logger=logger, sources=sources)
195180
res = solver.solve()
196181
sys.stderr.write(prof.report().to_text(lines=40))
197182
else:
198-
solver = SSSPSolver(
199-
G, sources[0], config=cfg, logger=logger, sources=sources
200-
)
183+
solver = SSSPSolver(G, sources[0], config=cfg, logger=logger, sources=sources)
201184
res = solver.solve()
202185
wall_ms = (time.perf_counter() - t0) * 1000.0
203186
_, peak = tracemalloc.get_traced_memory()
@@ -207,15 +190,11 @@ def main(argv: Optional[List[str]] = None) -> int:
207190
t0 = time.perf_counter()
208191
if args.profile:
209192
with ProfileSession(dump_path=args.profile_out) as prof:
210-
solver = SSSPSolver(
211-
G, sources[0], config=cfg, logger=logger, sources=sources
212-
)
193+
solver = SSSPSolver(G, sources[0], config=cfg, logger=logger, sources=sources)
213194
res = solver.solve()
214195
sys.stderr.write(prof.report().to_text(lines=40))
215196
else:
216-
solver = SSSPSolver(
217-
G, sources[0], config=cfg, logger=logger, sources=sources
218-
)
197+
solver = SSSPSolver(G, sources[0], config=cfg, logger=logger, sources=sources)
219198
res = solver.solve()
220199
wall_ms = (time.perf_counter() - t0) * 1000.0
221200
peak_mib = None

src/ssspx/frontier.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ def pull(self) -> Tuple[Set[Vertex], Float]:
186186

187187
got = self._consume_block_prefix(self._d0, self.M, chosen, pulled_keys)
188188
if got < self.M:
189-
got += self._consume_block_prefix(
190-
self._d1, self.M - got, chosen, pulled_keys
191-
)
189+
got += self._consume_block_prefix(self._d1, self.M - got, chosen, pulled_keys)
192190
new_bounds: List[Float] = []
193191
for blk in self._d1:
194192
if blk:

src/ssspx/io.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,7 @@ def _read_graphml(path: Path) -> Tuple[int, EdgeList]:
228228
w_attr = edge.attrib.get("weight")
229229
if w_attr is None:
230230
data = edge.find(f"{ns}data[@key='w']")
231-
w = (
232-
float(data.text)
233-
if (data is not None and data.text is not None)
234-
else 1.0
235-
)
231+
w = float(data.text) if (data is not None and data.text is not None) else 1.0
236232
else:
237233
w = float(w_attr)
238234
edges.append((u, v, w)) # Now u and v are definitely integers

0 commit comments

Comments
 (0)