Repository navigation
fix(visualization): plot_event_study accepts WooldridgeDiDResults; pin the tutorial event-study idiom - #905
Conversation
…n the event-study idiom on all 13 producers
Passing a WooldridgeDiDResults (what its aggregate('event_study') returns)
raised KeyError: 'effect' because its native dict is keyed 'att'. Convert it
to the unified EventStudyResults container at entry so it takes the container
route end to end: stored intervals drawn as-is, stored-alpha mismatch warning,
no error bars for the fail-closed cohort_share aggregation. An un-aggregated
fit raises the surface builder's ValueError naming the call to make.
Add a contract test for the event-study idiom the tutorials teach
(es = results.aggregate('event_study') where the class has aggregate, else the
result; plot_event_study(es)) across all thirteen event-study producers.
Log library gaps found by the 4.0 tutorial review in TODO.md.
…defined stored inference On the container route, a row whose stored pointwise interval is NaN (for example WooldridgeDiD weights='cohort_share': finite conditional-on-shares SE, fail-closed t/p/CI) now gets a NaN SE before the explicit reference_period= path recomputes intervals from the SE, so no interval is drawn for it on either backend.
Overall assessment: ✅ Looks goodNo unmitigated P0 or P1 findings identified. Executive summary
Methodology
Code QualityNo findings. Conversion reuses the existing container route, and normalization creates local dictionaries without changing stored results. Empty plot data retains its explicit PerformanceNo findings. Additional masking is linear in the number of event-study periods. MaintainabilityNo findings. Reusing container extraction avoids duplicating Wooldridge-specific interval and coverage handling. Tech Debt
SecurityNo findings in the changed content. Documentation/Tests
The required changelog fragment is present and passes validation. Runtime test results remain unverified in this environment. |
…indices The WooldridgeDiD plotting example added to docs/api/visualization.rst is a new code block near the top of the page, so the three context-dependent snippets below it (formerly blocks 2, 3 and 9) are now blocks 3, 4 and 10.
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: ✅ Looks goodNo unmitigated P0 or P1 findings identified. Executive summary
Methodology
Code QualityNo findings. The change reuses container extraction, avoids mutating stored results, and retains the empty-data PerformanceNo findings. Conversion and masking require linear work in the number of event-study rows. MaintainabilityNo findings. Reusing the unified container route keeps interval handling and coverage warnings consistent. Tech Debt
SecurityNo findings in the changed content. Documentation/Tests
The required changelog fragment is present and passes validation. Changed Python files and visualization documentation snippets compile successfully. Runtime tests remain unverified because pytest, NumPy, pandas, SciPy, matplotlib, and plotly are unavailable. |
Summary
plot_event_study(WooldridgeDiDResults)raisedKeyError: 'effect'(the Wooldridge event-study dict is keyedatt, andaggregate("event_study")returns the results object itself rather than a container). The result is now converted to the unifiedEventStudyResultscontainer at the top ofplot_event_study, so it takes the existing container route end to end: stored intervals are drawn as-is, the stored-alphamismatch warning applies, and a fit on whichaggregate("event_study")has not been called raises the surface builder'sValueErrornaming that call.reference_period=. That path discards the stored intervals and recomputes from the SE, which would have redrawn inference a producer had deliberately disabled (WooldridgeDiDweights="cohort_share"keeps a finite conditional-on-shares SE while t/p/CI fail closed to NaN). The point estimates still plot, normalized. Applies before backend dispatch, so matplotlib and plotly agree.es = results.aggregate("event_study")where the class hasaggregate, else the result;plot_event_study(es); table from the container orto_dataframe(level="event_study")) is pinned on all thirteen event-study producers. This is the first PR of the post-4.0 tutorial repair; the tutorial convention PR cites this test.TODO.md: seven library gaps found while reviewing the tutorials against 4.0 (each re-verified by execution), and the existing SunAbraham NaN-overall-ATT row gains a reproduction on the bundled divorce panel.Methodology references (required if estimator / math changes)
plot_event_study); no estimator, weighting or variance formula changes.docs/methodology/REGISTRY.md, "Event Study Plotting", gains a Note for the Wooldridge route and the normalization guarantee.Validation
tests/test_visualization.py-TestPlotEventStudyWooldridge(stored surface plotted exactly; parity with the container route; un-aggregated fit raises; stored-alpha warning; cohort-share draws no error bars, including under explicitreference_period=with bothuse_cbandvalues on both backends; cell-weighted normalization keeps its recomputed intervals) andTestEventStudyIdiomContract(13 producers, plus a pin on which producers take which route).Security / privacy
Changelog