Commit 8ecbaf7
Fix latent doc-snippet bugs from PR igerber#389 (HAD ecosystem)
PR igerber#389 added HAD code snippets to choosing_estimator.rst,
troubleshooting.rst, and r_comparison.rst. None of those edits
triggered rust-test.yml (which only runs on rust/, diff_diff/, tests/,
pyproject.toml, and the workflow file), so tests/test_doc_snippets.py
never executed and the snippets shipped with five latent bugs that now
surface on every code PR via the Pure Python Fallback job.
Bugs addressed:
- r_comparison:block6 — bare HAD.fit(data, ...) with the
generate_staggered_data fixture failed because the default
aggregate='overall' requires exactly 2 periods and the namespace
data has 10. Replaced with an inline HAD-shape panel construction
(mirrors the upstream choosing_estimator:block7 fix in 55d7a27)
plus aggregate='event_study'.
- troubleshooting:block20 — the snippet demonstrates
first_treat_col= auto-filtering on a staggered panel. The fixture's
first_treat values disagree with the dose path (random per-row dose
on never-treated units), tripping HAD's first_treat / dose-path
consistency validator. Inlined a 120-unit / 10-period staggered
HAD-shape panel (30 never + 30 cohort 5 + 60 cohort 8) so the
validator passes and the boundary local-linear estimator has
enough distinct dose values to fit.
- troubleshooting:block17 / block18 / r_comparison:block7 — these are
legitimately context-dependent snippets that reference est /
results from prior text-flow context (inspection / output-format
examples). Added them to _CONTEXT_DEPENDENT_SNIPPETS so the
expected NameError is suppressed, matching the pattern already
used for block8, the api_bacon blocks, and the existing
r_comparison context-dependent set.
choosing_estimator:block7 was the sixth failing snippet but was
already fixed upstream in 55d7a27 with the inline-construction
pattern; this branch rebases onto that.
Verification: PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest
tests/test_doc_snippets.py reports 111 passed, 4 skipped, 0 failed
on this branch (was 6 failed on origin/main before 55d7a27 and 5
failed after).
Follow-up (separate PR queued): carve test_doc_snippets.py out into a
dedicated docs-tests.yml workflow triggered on docs/** + diff_diff/**
+ the test file itself, and exclude it from rust-test.yml's pytest
invocations so doc bugs are caught on doc PRs (not silently inherited
by code PRs).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b560c80 commit 8ecbaf7
3 files changed
Lines changed: 46 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
242 | 258 | | |
243 | | - | |
244 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
245 | 262 | | |
246 | 263 | | |
247 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
596 | 620 | | |
597 | 621 | | |
598 | 622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
| 369 | + | |
369 | 370 | | |
| 371 | + | |
| 372 | + | |
370 | 373 | | |
371 | 374 | | |
372 | 375 | | |
| |||
0 commit comments