test(statistics): presentation coverage for print_summary/plot_summary (#260) - #282
Merged
Merged
Conversation
#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 intests/test_statistics_presentation.py, in the repo that owns the code.Covers #260's two named risks directly:
map,min,max,mass_at_zero,bimodal,pinned_masses,hdis) is exercised end-to-end throughanalyze()— the next key rename fails here first, not at report-generation time.plot_summary(save_path=…)is verified by a real PNG write (existence + magic bytes + size) — the relic suite mockedsavefig, 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). NowOptional[TextIO] = None, resolved to the currentsys.stdoutat call time. No caller in either repo passedfileexplicitly (grepped both).Riders
TestPDAPresentation/TestPDAFailureModes/TestPDAInteractiveSafety) and now lists the real classes + the new file.print_summarydocstring 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