Skip to content

Fix power analysis notebook plot rendering and suppress SDID warning#228

Merged
igerber merged 1 commit intomainfrom
fix-power-analysis-notebook
Mar 22, 2026
Merged

Fix power analysis notebook plot rendering and suppress SDID warning#228
igerber merged 1 commit intomainfrom
fix-power-analysis-notebook

Conversation

@igerber
Copy link
Owner

@igerber igerber commented Mar 21, 2026

Summary

  • Add %matplotlib inline magic and explicit plt.show() calls to 4 plotting cells so plots render in all Jupyter environments
  • Wrap SyntheticDiD simulate_power() call in warnings.catch_warnings() to suppress structural factor-model DGP warnings in the tutorial

Methodology references (required if estimator / math changes)

  • N/A — no methodology changes

Validation

  • Tests added/updated: No test changes
  • Backtest / simulation / notebook evidence: Notebook executed end-to-end via nbconvert --execute — all 4 plots produce image/png output, SyntheticDiD cell has no warnings

Security / privacy

  • Confirm no secrets/PII in this PR: Yes

Generated with Claude Code

Add %matplotlib inline and explicit plt.show() calls to ensure plots
render in all Jupyter environments. Wrap SyntheticDiD simulation in
warnings.catch_warnings() to suppress structural factor-model DGP
warnings in the tutorial.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions
Copy link

Overall Assessment

✅ Looks good

Executive Summary

  • This is a docs-only PR. It does not change estimator code, weighting, variance/SE computation, identification checks, or defaults in the library itself.
  • The only affected method from a methodology standpoint is the SyntheticDiD tutorial example. The suppressed warning is the documented poor pre-treatment-fit diagnostic, and the example still satisfies the registry’s placebo requirement that controls outnumber treated units.
  • I found no unmitigated P0/P1 issues in methodology, inference, assumption checks, or edge-case handling within the changed scope.
  • One minor P3 maintainability issue remains: the new explicit plt.show() calls are redundant because plot_power_curve() already calls plt.show() by default.

Methodology

No findings. The affected method is limited to the SyntheticDiD power-analysis tutorial example in docs/tutorials/06_power_analysis.ipynb:L437-L443. The warning being suppressed is the documented Pre-treatment fit is poor diagnostic emitted by diff_diff/synthetic_did.py:L383-L397, and the Methodology Registry explicitly classifies it as diagnostic-only with estimation proceeding docs/methodology/REGISTRY.md:L1123. The notebook also keeps treatment_fraction=0.3, which is consistent with the documented and enforced placebo-variance requirement n_control > n_treated docs/methodology/REGISTRY.md:L1113-L1114 diff_diff/power.py:L1537-L1552.

Code Quality

No findings. The new warning suppression is narrowly scoped to a single tutorial cell via warnings.catch_warnings() and a specific message filter in docs/tutorials/06_power_analysis.ipynb:L443, so it does not weaken the library’s runtime warning behavior.

Performance

No findings. The notebook-only changes have no material algorithmic or runtime impact on library code.

Maintainability

Tech Debt

No findings. Nothing in this PR needs TODO.md tracking.

Security

No findings. This is a notebook-only change with no secret-handling, network, or privilege-sensitive additions.

Documentation/Tests

No findings. I did not execute the notebook during this review; this assessment is based on static inspection of the changed cells and the relevant implementation/registry references.

@igerber igerber merged commit 759616b into main Mar 22, 2026
2 checks passed
@igerber igerber deleted the fix-power-analysis-notebook branch March 22, 2026 00:38
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