Testing
Running Tests
From the project root:
pixi run -e dev check-import
pixi run -e dev test
With coverage:
pixi run -e dev test-cov
Then build the documentation (which executes the tutorials) and run the tutorial dataset end to end:
pixi run -e docs docs-build
TFOPT_CONFIG=notebooks/data/toy.toml pixi run tfopt-local
The test configuration is in pytest.ini; tests/conftest.py selects notebooks/data/toy.toml. The tests use small
synthetic inputs and need no files from data/ (which is not tracked). Zero collected tests, skipped tests or
non-converged fits never count as validation success.
Test files
| File | What it checks |
|---|---|
tests/test_numerics.py |
All seven losses against values captured from the original Numba objective (tests/fixtures/legacy_oracle.json, TFOpt baseline 6510062) within 1e-12; clipping and padded-α exclusion; the regularization |
tests/test_constraints.py |
Parameter geometry (groups, bounds, projection), signed β, infeasible bounds, fixed-zero β, the non-negative method, the compiled projection |
tests/test_optimization.py |
Each method's fit and failure reporting; multistart ranking (feasible fits by objective before round-off residuals); polishing; LBFGSB recovery from a collapsed α stick; acceptance only for success within 1e-10 |
tests/test_slsqp.py |
scipy-slsqp with exact constraints and analytic gradients; parallel starts identical to sequential ones |
tests/test_constraint_residual.py |
Σα = 1 per target and Σβ = 1 per TF to within 1e-10 after optimization |
tests/test_kkt_diagnostics.py |
KKT multipliers and the four residuals, as KinOpt 0.11 |
tests/test_prediction_transform.py |
prediction_transform clip, none, softplus in the objective, Estimated and fit-analysis |
tests/test_t6_series.py |
TF base series (T6) and time alignment (T6c); see TF Base Series |
tests/test_pipeline.py |
Bad inputs and mapping, metric edge cases, the end-to-end CSV-to-report run, start_seed, the opt-in, non-overwriting ODE copy |
tests/test_api.py |
tfopt.api, the tfopt command and the example project |
tests/test_bundle.py |
Run bundles: round trip, hashes, tampering, the contract |
tests/test_app.py |
tfopt-app: token check, loopback binding, path traversal, upload limits |
tests/test_analysis.py |
Workbook schema, identifier and time-column alignment, invalid grids, missing signals reported (not zeroed), the Source column, TF removal, Fréchet distances |
tests/test_analysis_interfaces.py |
Imports without the optional viz packages, contributor metadata, no obsolete roots or imports, the diagrams and a missing renderer |
tests/test_architecture.py, tests/check_imports.py |
Every module imports without parent checkouts or forbidden packages |
tests/test_import_side_effects.py |
Importing TFOpt creates no file or folder |
tests/test_packaging.py |
Dependencies, distribution layout and version |
tests/test_repository.py |
Generated folders are ignored by git |
tests/test_docs_tutorials.py |
Every notebook is a page of the docs navigation; the docs build renders the tutorials first; the rendered tutorials are not tracked |
tests/test_docs_assets.py |
The brand marks are the output of tools/build_brand.py and use no font outlines; the site's logo, favicon, footer and navigation; no page refers to removed pages, scripts or the dashboard, or presents a default time grid |
tests/test_use_cases.py |
The three use cases of the docs (docs/examples/) run as published on the synthetic example |
Writing tests
Write the test first and see it fail; scientific behaviour changes need a regression test. Use synthetic inputs (the
problem fixture of tests/conftest.py, the tutorial dataset in notebooks/data/, or tfopt.examples) and
tmp_path for files; do not depend on data/ or on results folders. Do not claim convergence or feasibility without
measuring both.
Validation record
What was run when the standalone package was validated (Linux x86-64; macOS resolutions are in pixi.lock, macOS
execution was not tested). These are records of those runs, not guarantees for later versions.
| Command or check | Observed result |
|---|---|
pixi run -e dev check-import |
All modules imported without parent checkouts |
pixi run -e dev test-cov |
53 tests passed, none skipped; 58 % in-process coverage (objective and prediction core 100 %, optimizer runner 95 %, feasibility geometry 95 %; the end-to-end runs in separate processes are not counted) |
pixi run -e docs docs-build |
No documentation issues reported |
TFOPT_CONFIG=notebooks/data/toy.toml pixi run tfopt-local |
CSV-to-report pipeline passed; the known α and β recovered, MSE about 2.1e-15, constraint violation 0, projected-gradient infinity norm about 1.56e-8 |
TFOPT_CONFIG=notebooks/data/toy.toml pixi run tfopt-fitanalysis |
Every retained fit-analysis plot drawn |
| Notebooks 00–09 | Executed in separate kernels |
| Readout, curve similarity, figures and diagrams on the tutorial dataset | Nine readout tables; five aligned complete curves; ten figure families in PNG, SVG and PDF; two diagrams with the configured bounds |
| Docker build (with a temporary proxy CA), then the tutorial dataset | Passed |
The regression fixture was captured by executing the original TFOpt Numba objective before the JAX port; all seven
losses and positive predictions match within 1e-12 relative tolerance. The tutorial dataset includes signed β
([1.2, -0.2]) and different regulator and site counts.
The ranking and collapsed-stick convergence defects were reproduced by tests before they were fixed: feasible fits are ranked by objective despite round-off-sized violations, a collapsed α stick is recovered, and refinement that exhausts its iteration budget reports failure.
Limits. No production biological dataset and no macOS runtime were validated with these runs. Local convergence does not prove global optimality or unique identifiability; MAE/L1 and the clip are nonsmooth. JAXopt prints an upstream maintenance deprecation warning, and the retained plotting methods emit upstream Matplotlib/Seaborn warnings.