Skip to content

test: hardening + branch coverage in CI - #65

Merged
neuromechanist merged 2 commits into
mainfrom
61-test-hardening-edge-cases-+-numerical-stability-regressions
Jul 7, 2026
Merged

neuromechanist merged 2 commits into
mainfrom
61-test-hardening-edge-cases-+-numerical-stability-regressions

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #61. Closes #64. Addresses #15.

Folds test hardening together with actionable code coverage, all self-contained in GitHub CI (no external service).

Coverage tooling (#64)

  • Added [tool.coverage] config: branch coverage, omit tests + the argparse CLI, exclude pragmas.
  • Added pytest-xdist; CI now runs pytest -m "not slow" -n auto --cov-fail-under=80 and uploads the HTML report as an artifact.
  • CI-time benchmark (your ask): the suite is dominated by the real torch fits, not coverage. Parallel branch-coverage run is 2m36s locally (14 cores) vs 4m31s serial no-coverage; CI on bench: NG vs Fortran runtime harness (#59) #62 was 6m44s serial. -n auto more than pays for coverage, so on GitHub's 4-vCPU runners this should land ~3-4 min.

Test isolation fix (surfaced by -n auto)

TestAMICA used a shared relative test_data/ dir and rmtreed it in teardown, racing across xdist workers (FileNotFoundError). Switched to a unique mkdtemp dir.

Hardening tests

Coverage result

Total branch coverage 78.3% -> 81.1%; amica.py 86% -> 96%. Suite 85 -> 103 tests, 0 errors.

Note on #15

The AMICA.save/load roundtrip #15 asked for is already covered (test_amica_ng_wrapper.py, added under #36 after #15 was filed). plot_components builds a figure but never writes a file, so #15's 'assert files are written' does not literally apply; covered its activation branch instead.

Add [tool.coverage] config (branch coverage, omit tests + CLI, exclude pragmas) and pytest-xdist. CI now runs 'pytest -m "not slow" -n auto --cov-fail-under=78' and uploads the HTML report as an artifact. Parallel branch-cov local run is 2m59s vs 4m31s serial-no-cov (14 cores). Fix a test-isolation bug the parallelism surfaced: TestAMICA used a shared relative test_data/ dir and rmtree'd it in teardown, racing under xdist; use a unique mkdtemp dir. Baseline 78.3% branch coverage. Refs #64, #61.
Add test_ng_utils.py (torch_impl/utils device/stability/correlation/loader, 20->65%) and test_edge_cases.py (non-2D input, single-channel/single-sample graceful handling, from_params_file, load missing-key branch). Cover plot_components activation branch. amica.py 86->96%. Total branch coverage 78.3->81.1%; ratchet the CI gate to 80. #15 save/load was already covered under #36. Refs #61, #15, #64.
@neuromechanist neuromechanist linked an issue Jul 7, 2026 that may be closed by this pull request
3 tasks
@neuromechanist
neuromechanist merged commit 12d4ba7 into main Jul 7, 2026
5 checks passed
@neuromechanist
neuromechanist deleted the 61-test-hardening-edge-cases-+-numerical-stability-regressions branch July 7, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add branch coverage config + CI gate + artifact Test hardening: edge cases + numerical-stability regressions

1 participant