Skip to content

Commit fa35f47

Browse files
committed
chore: move CI and dev tooling to uv
1 parent 7ca9ac9 commit fa35f47

11 files changed

Lines changed: 850 additions & 760 deletions

.github/workflows/ci.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@ on:
99
pull_request:
1010

1111
jobs:
12+
pre-commit:
13+
name: Pre-commit
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install uv and Python
21+
uses: astral-sh/setup-uv@v7
22+
with:
23+
python-version: "3.13"
24+
enable-cache: true
25+
26+
- name: Set up Rust
27+
uses: dtolnay/rust-toolchain@stable
28+
with:
29+
components: clippy, rustfmt
30+
31+
- name: Sync lint environment
32+
run: uv sync --locked --only-group lint
33+
34+
- name: Run pre-commit
35+
run: uv run pre-commit run --all-files
36+
1237
python-tests:
1338
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
1439
runs-on: ${{ matrix.os }}
@@ -29,27 +54,20 @@ jobs:
2954
- name: Check out repository
3055
uses: actions/checkout@v4
3156

32-
- name: Set up Python
33-
uses: actions/setup-python@v5
57+
- name: Install uv and Python
58+
uses: astral-sh/setup-uv@v7
3459
with:
3560
python-version: ${{ matrix.python-version }}
61+
enable-cache: true
3662

3763
- name: Set up Rust
3864
uses: dtolnay/rust-toolchain@stable
3965

40-
- name: Cache Rust artifacts
41-
uses: Swatinem/rust-cache@v2
42-
43-
- name: Install test dependencies
44-
run: |
45-
python -m pip install --upgrade pip
46-
python -m pip install pytest scipy
47-
48-
- name: Install package
49-
run: python -m pip install .
66+
- name: Sync test environment
67+
run: uv sync --locked --only-group test
5068

5169
- name: Run test suite
52-
run: pytest -x -v
70+
run: uv run pytest -x -v
5371

5472
rust-checks:
5573
name: Rust checks

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
- id: mypy
2121
additional_dependencies: [numpy]
2222
args: [--strict]
23-
exclude: '(\.pyi$|tests/)'
23+
exclude: '(\.pyi$|tests/|examples/)'
2424
- repo: local
2525
hooks:
2626
- id: cargo-fmt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ pre-commit run --all-files # ruff, mypy, cargo fmt, cargo clippy
127127

128128
## License
129129

130-
BSD-3-Clause
130+
BSD-3-Clause

examples/adaptive_learnernd.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99

1010
import time
1111

12-
import numpy as np
13-
1412
import adaptive_triangulation as at
13+
import numpy as np
1514
from adaptive.learner import learnerND as lnd_mod
1615
from adaptive.learner.learnerND import LearnerND
1716

@@ -51,4 +50,4 @@ def ring_of_fire(xy: tuple[float, float]) -> float:
5150
learner_rust.tell(p, ring_of_fire(p))
5251
t_rust = time.perf_counter() - t0
5352
print(f"Rust triangulation: {t_rust:.2f}s ({n_points} points)")
54-
print(f"Speedup: {t_python / t_rust:.1f}×")
53+
print(f"Speedup: {t_python / t_rust:.1f}×")

examples/basic_usage.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
"""
66

77
import numpy as np
8-
98
from adaptive_triangulation import Triangulation, circumsphere, volume
109

1110
# Create a 2D triangulation from initial points
1211
points = [(0.0, 0.0), (1.0, 0.0), (0.0, 1.0), (1.0, 1.0)]
1312
tri = Triangulation(points)
14-
1513
print(f"Vertices: {len(tri.vertices)}")
1614
print(f"Simplices: {len(tri.simplices)}")
1715
print(f"Dimension: {tri.dim}")
1816

17+
1918
# Add a point incrementally (Bowyer-Watson insertion)
2019
deleted, added = tri.add_point((0.5, 0.5))
21-
print(f"\nAfter adding (0.5, 0.5):")
20+
print("\nAfter adding (0.5, 0.5):")
2221
print(f" Deleted simplices: {len(deleted)}")
2322
print(f" Added simplices: {len(added)}")
2423
print(f" Total simplices: {len(tri.simplices)}")
@@ -42,4 +41,4 @@
4241

4342
# Check invariants
4443
assert tri.reference_invariant(), "Triangulation invariant violated!"
45-
print("\nAll invariants passed ✓")
44+
print("\nAll invariants passed ✓")

examples/benchmark_vs_python.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
import time
88

9-
import numpy as np
10-
119
import adaptive_triangulation as at
10+
import numpy as np
1211

1312
# Try importing Python reference
1413
try:
@@ -69,11 +68,12 @@ def bench_python(points: list[tuple[float, ...]], dim: int) -> float:
6968
print(f"{'Dim':>3} {'N':>6} {'Rust':>10} {'Python':>10} {'Speedup':>8}")
7069
print("-" * 45)
7170

71+
7272
for dim, sizes in configs:
7373
for n in sizes:
7474
points = generate_points(n, dim)
7575
# Best of 3
7676
t_rust = min(bench_rust(points, dim) for _ in range(3))
7777
t_py = min(bench_python(points, dim) for _ in range(3))
7878
speedup = t_py / t_rust if t_rust > 0 else float("nan")
79-
print(f"{dim:>3} {n:>6} {t_rust:>9.3f}s {t_py:>9.3f}s {speedup:>7.1f}×")
79+
print(f"{dim:>3} {n:>6} {t_rust:>9.3f}s {t_py:>9.3f}s {speedup:>7.1f}×")

pyproject.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,19 @@ dependencies = [
2727
"numpy>=1.24",
2828
]
2929

30-
[project.optional-dependencies]
31-
test = ["pytest>=7.0", "scipy>=1.10"]
30+
[dependency-groups]
31+
dev = [
32+
{ include-group = "lint" },
33+
{ include-group = "test" },
34+
]
35+
lint = [
36+
"pre-commit",
37+
]
38+
test = [
39+
"adaptive",
40+
"pytest>=7.0",
41+
"scipy>=1.10",
42+
]
3243

3344
[project.urls]
3445
Homepage = "https://github.com/python-adaptive/adaptive-triangulation"
@@ -51,6 +62,7 @@ ignore = ["D", "COM812", "ISC001"]
5162
[tool.ruff.lint.per-file-ignores]
5263
"tests/*" = ["S101", "PLR2004", "ANN"]
5364
"benchmarks/*" = ["T201", "ANN", "S101"]
65+
"examples/*" = ["INP001", "T201", "S101", "N813", "RUF001", "RUF002", "SIM105", "PERF203"]
5466

5567
[tool.mypy]
5668
strict = true

0 commit comments

Comments
 (0)