Skip to content

test(statistics): presentation coverage for print_summary/plot_summary (#260) - #282

Merged
Polichinel merged 1 commit into
developmentfrom
test/260-presentation-coverage
Aug 13, 2026
Merged

test(statistics): presentation coverage for print_summary/plot_summary (#260)#282
Polichinel merged 1 commit into
developmentfrom
test/260-presentation-coverage

Conversation

@Polichinel

Copy link
Copy Markdown
Contributor

What

Closes the #260 coverage gap: PosteriorDistributionAnalyzer.print_summary()/plot_summary() were untested in either repo after pipeline-core #316 pruned their relic suite (the only coverage anywhere). 14 new tests in tests/test_statistics_presentation.py, in the repo that owns the code.

Covers #260's two named risks directly:

  • KeyError-on-rename: every summary-dict key the methods consume (map, min, max, mass_at_zero, bimodal, pinned_masses, hdis) is exercised end-to-end through analyze() — the next key rename fails here first, not at report-generation time.
  • Silent savefig: plot_summary(save_path=…) is verified by a real PNG write (existence + magic bytes + size) — the relic suite mocked savefig, which is exactly how "silently stops writing files" escapes.

Also pins the current labels (the relic still asserted the pre-tower MAP estimate:), HDI lines per pinned canonical mass, figure structure, show semantics, and the bimodal title caveat (flag injected both directions — detection is the tower's contract, not ours).

Fix the tests caught (RED-proven)

print_summary(self, file: TextIO = sys.stdout) froze the import-time stdout, silently bypassing later redirection (pytest capture, contextlib.redirect_stdout). Now Optional[TextIO] = None, resolved to the current sys.stdout at call time. No caller in either repo passed file explicitly (grepped both).

Riders

  • CIC Test Alignment section corrected — it attributed presentation coverage to classes that don't exist (TestPDAPresentation/TestPDAFailureModes/TestPDAInteractiveSafety) and now lists the real classes + the new file.
  • print_summary docstring Example/Note updated to the actual output.

Review

Two adversarial rounds (round 1: 3 findings — stale CIC, asymmetric bimodal-flag coupling, stale docstring Example — all fixed; round 2: 2 doc nits, fixed; round 3 text-only, verified). Suite: 443 passed, 2 skipped, 1 xfailed; ruff clean.

Closes #260

🤖 Generated with Claude Code

#260)

pipeline-core #316 pruned their relic suite — the ONLY tests anywhere for
the analyzer's presentation methods. This adds the coverage in the repo
that owns the code (tests/test_statistics_presentation.py, 14 tests):

- print_summary: before-analyze guard; CURRENT labels ("Point estimate
  (tower tip)", the relic still asserted the pre-tower "MAP estimate");
  printed values/formats match the summary dict; one HDI line per PINNED
  mass; call-time stdout resolution (redirect respected).
- plot_summary: before-analyze guard returns None; Figure structure (point
  line at the tip, legend "% HDI" label per pinned mass); show=False/True
  semantics; bimodal title caveat (flag injected both directions —
  detection is the tower's contract, not ours); save_path verified by a
  REAL PNG write (existence + magic bytes + size) — the relic mocked
  savefig, which is how "silently stops writing files" escapes.

Every summary key the methods consume is exercised end-to-end through
analyze(), so the next key rename fails here first, not as a KeyError at
report-generation time (#260's stated bite).

Fix the tests caught (RED-proven): print_summary's `file: TextIO =
sys.stdout` default froze the IMPORT-time stream, silently bypassing later
redirection (pytest capture, contextlib.redirect_stdout). Now
`Optional[TextIO] = None`, resolved to the current sys.stdout at call
time. No caller passed `file` explicitly (both repos grepped).

Riders: CIC Test Alignment section corrected (it attributed presentation
coverage to classes that don't exist — TestPDAPresentation/
TestPDAFailureModes/TestPDAInteractiveSafety); print_summary docstring
Example/Note updated to the actual output.

Closes #260

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Polichinel
Polichinel merged commit fca7078 into development Aug 13, 2026
1 check passed
@Polichinel
Polichinel deleted the test/260-presentation-coverage branch August 13, 2026 01:28
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.

1 participant