-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnoxfile.py
More file actions
191 lines (164 loc) · 5.15 KB
/
noxfile.py
File metadata and controls
191 lines (164 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
"""Local development sessions mirroring the main CI entry points."""
from __future__ import annotations
import nox
PYTHON_DEFAULT = "3.13"
def _poetry_install(session: nox.Session, *args: str) -> None:
session.run("poetry", "install", *args, external=True)
@nox.session(python=PYTHON_DEFAULT)
def tests_numpy(session: nox.Session) -> None:
"""Run the default NumPy test suite."""
_poetry_install(session, "--with", "dev", "--extras", "healpy_support")
session.env["PYRECEST_BACKEND"] = "numpy"
session.run(
"poetry",
"run",
"python",
"-m",
"pytest",
"--rootdir",
".",
"-v",
"./tests",
external=True,
)
@nox.session(python=PYTHON_DEFAULT)
def tests_pytorch(session: nox.Session) -> None:
"""Run the PyTorch backend test suite."""
_poetry_install(
session, "--with", "dev", "--extras", "healpy_support pytorch_support"
)
session.env["PYRECEST_BACKEND"] = "pytorch"
session.run(
"poetry",
"run",
"python",
"-m",
"pytest",
"--rootdir",
".",
"-v",
"./tests",
external=True,
)
@nox.session(python=PYTHON_DEFAULT)
def tests_jax(session: nox.Session) -> None:
"""Run the JAX backend test suite."""
_poetry_install(session, "--with", "dev", "--extras", "healpy_support jax_support")
session.env["PYRECEST_BACKEND"] = "jax"
session.env["JAX_ENABLE_X64"] = "True"
session.run(
"poetry",
"run",
"python",
"-m",
"pytest",
"--rootdir",
".",
"-v",
"./tests",
external=True,
)
@nox.session(python=PYTHON_DEFAULT)
def docs(session: nox.Session) -> None:
"""Build documentation in strict mode."""
_poetry_install(session, "--with", "docs", "--without", "dev")
session.env["PYTHONPATH"] = "src"
session.run("poetry", "run", "mkdocs", "build", "--strict", external=True)
@nox.session(python=PYTHON_DEFAULT)
def numerical_stress(session: nox.Session) -> None:
"""Run slower numerical-stability tests."""
_poetry_install(session, "--with", "dev", "--extras", "healpy_support")
session.env["PYRECEST_BACKEND"] = "numpy"
session.run(
"poetry",
"run",
"python",
"-m",
"pytest",
"--rootdir",
".",
"-v",
"-m",
"numerical_stress",
"./tests",
external=True,
)
@nox.session(python=PYTHON_DEFAULT)
def benchmarks(session: nox.Session) -> None:
"""Run optional benchmark tests."""
_poetry_install(session, "--with", "dev")
session.env["PYRECEST_BACKEND"] = "numpy"
session.run(
"poetry",
"run",
"python",
"-m",
"pytest",
"-m",
"benchmark",
"./benchmarks",
external=True,
)
@nox.session(python=PYTHON_DEFAULT)
def lint(session: nox.Session) -> None:
"""Run focused static checks that are expected to stay clean."""
session.install("ruff>=0.8,<1.0")
session.run("ruff", "check", ".")
@nox.session(python=PYTHON_DEFAULT)
def package(session: nox.Session) -> None:
"""Build distributions and validate local release metadata."""
session.install("build", "twine")
session.run("python", "scripts/check_release_consistency.py", "--local-only")
session.run("python", "-m", "build")
session.run("sh", "-c", "python -m twine check dist/*", external=True)
@nox.session(python=PYTHON_DEFAULT)
def minimal_install(session: nox.Session) -> None:
"""Install the default package only and run a public API smoke check."""
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
session.run("python", "-m", "pip", "install", ".")
session.run(
"python",
"-c",
(
"import pyrecest; "
"from pyrecest.backend import array, diag; "
"from pyrecest.filters import KalmanFilter; "
"kf = KalmanFilter((array([0.0, 1.0]), diag(array([1.0, 1.0])))); "
"print(pyrecest.__version__, kf.get_point_estimate())"
),
)
@nox.session(python=PYTHON_DEFAULT)
def benchmark_regressions(session: nox.Session) -> None:
"""Run deterministic benchmark scenarios and compare numerical outputs."""
_poetry_install(session, "--with", "dev")
session.env["PYRECEST_BACKEND"] = "numpy"
session.run(
"poetry",
"run",
"python",
"benchmarks/basic_regressions.py",
"--output",
"benchmark-results.json",
external=True,
)
session.run(
"poetry",
"run",
"python",
"scripts/check_benchmark_results.py",
"benchmark-results.json",
"--baseline",
"benchmarks/baselines/basic_regressions.json",
external=True,
)
@nox.session(python=PYTHON_DEFAULT)
def typecheck_core(session: nox.Session) -> None:
"""Run a strict typing lane for stable, low-dependency modules."""
session.install("mypy>=1.12,<2.0")
session.env["PYTHONPATH"] = "src"
session.run(
"mypy",
"src/pyrecest/diagnostics.py",
"src/pyrecest/reproducibility.py",
"src/pyrecest/scenarios.py",
)