Skip to content

fix(identification): warn once per posterior on weak max-share identification - #229

Draft
thomaspinder wants to merge 1 commit into
feat/145-max-share-identificationfrom
fix/202-weak-id-warning-dedup
Draft

fix(identification): warn once per posterior on weak max-share identification#229
thomaspinder wants to merge 1 commit into
feat/145-max-share-identificationfrom
fix/202-weak-id-warning-dedup

Conversation

@thomaspinder

Copy link
Copy Markdown
Owner

Summary

Follow-up on the max-share branch (#200), stacked on feat/145-max-share-identification:

MaxShare's weak-identification warning fired per identify() call with the eigen ratio embedded to 3 dp — under shock_matrix(at="all") with time-varying volatility the ratio varies with each period's Cholesky factor, defeating the warnings-registry dedup (measured: 76 warnings on one call). It now warns once per posterior, keyed alongside the spectral cache, on the first crossing rather than the first call (a healthy first period doesn't spend the posterior's one warning). The message states the once-per-posterior semantics and points at max_share_diagnostics() with an explicit L for the per-period picture. Per-call eigen-ratio diagnostics unchanged.

Tests include a ramped time-varying-volatility stub (all 199 periods weak, ~76 distinct ratios) pinning exactly one warning, a first-crossing-not-first-call pin, a fresh-posterior re-warn pin, and the constant-volatility regression pin. Reverting only the dedup guard fails 3 tests with the original 76-warning behaviour.

Closes #202

Gates

88 identification/pipeline tests green; branch fast suite 583 passed; ruff/ty clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV

@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.1%. Comparing base (7cac559) to head (1f58493).

Additional details and impacted files
@@                        Coverage Diff                        @@
##           feat/145-max-share-identification    #229   +/-   ##
=================================================================
  Coverage                               95.1%   95.1%           
=================================================================
  Files                                     45      45           
  Lines                                   3240    3247    +7     
  Branches                                 397     397           
=================================================================
+ Hits                                    3082    3089    +7     
  Misses                                   113     113           
  Partials                                  45      45           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thomaspinder
thomaspinder force-pushed the feat/145-max-share-identification branch 2 times, most recently from f06fbe5 to 5d5d731 Compare July 29, 2026 21:10
@thomaspinder
thomaspinder marked this pull request as draft July 29, 2026 22:01
`MaxShare._warn_weakly_identified` ran on every `identify()` call and
embedded the eigenvalue ratio to 3 dp. Under time-varying volatility the
ratio moves with `L_t`, so `shock_matrix(at="all")`'s per-t loop produced
a distinct message each period and Python's warnings registry deduped
nothing — up to T warnings for one call. The singular and explosive
warnings already fire once, via `_spectral_cache`, but the degeneracy
check depends on `L` and so cannot ride on that cache directly.

Track the cache key of the posterior the warning last fired for in a new
`_warned_weak_for` private attr and warn only on the first crossing per
posterior. `_band_eigen` now returns that key alongside the eigen
quantities, and both it and `_spectral_accumulator` derive it from a
shared `_cache_key` helper so the memoised sweep and the one-shot warning
agree on what "the same posterior" means. The message says it is warned
once per posterior and points at `max_share_diagnostics` for the
per-period picture; the per-call eigen-ratio diagnostics are unchanged.

Fixes #202

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV
@thomaspinder
thomaspinder force-pushed the fix/202-weak-id-warning-dedup branch from 70b9836 to 1f58493 Compare July 29, 2026 22:08
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.

2 participants