Repository navigation
docs(tutorials): tutorial conventions and a CI guard for them - #906
Conversation
CONTRIBUTING.md gains a 'Tutorial conventions' section: what every notebook states and how (estimand and assumptions, truth check on simulated data, clustered inference and which p-values are count-based, one event-study idiom, warnings, committed outputs, a drift test per notebook, reader voice), plus the recipe for re-executing a notebook. tests/test_tutorial_conventions.py enforces the mechanical rules over every notebook by parsing the notebook JSON: execution counts, no committed error output (never allowlistable), no removed 4.0 names or aliases, no internal jargon, no unqualified warning suppression, no em dashes, no HAS_MATPLOTLIB guard, a drift test per notebook. A ratchet allowlist records today's violations; repair PRs must shrink it. It runs in docs-tests.yml, and the workflow wiring is self-pinned. notebooks.yml now runs every tutorial drift test, so a notebook-only diff cannot leave its pinned numbers unchecked. docs/tutorials/README.md is reduced to a pointer to the tutorial index and the conventions.
Overall assessment: ✅ Looks goodNo unmitigated P0 or P1 findings. Two P2 issues remain. Executive summary
MethodologyNo methodology defects found. The permutation-test correction and SyntheticDiD placebo floor match the Code QualityP2 — Recognize aliased warning-filter importsLocation: Impact: Concrete fix: Resolve imports of warning-filter functions to their canonical names, including aliases imported in earlier cells. Add fixtures for both aliased functions, with blanket filters rejected and qualified filters accepted. PerformanceNo findings. The new guard parses notebook JSON without executing notebooks. MaintainabilityNo findings. Tech DebtNo additional findings. The existing violations and pending-notebook exemptions are explicitly documented as transitional. SecurityNo findings. Documentation/TestsP2 — Restore the unrelated Wang source reviewLocations: Impact: This removes the complete OVB methodology audit, including implementation requirements and unresolved inference questions, along with its release note. Neither deletion supports the tutorial-conventions change, and no replacement is present. Concrete fix: Restore both files; handle any intended withdrawal separately with an explicit rationale. |
…tions guard
from warnings import simplefilter as sf; sf('ignore') - or an assignment
alias, possibly created in an earlier cell - no longer bypasses the
blanket-warning-filter rule.
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: ✅ Looks goodBoth previous P2 findings are resolved. No unmitigated P0 or P1 findings. Executive summary
MethodologyNo defects found. The permutation formula No estimator, variance, weighting, or identification behavior changes. Code QualityPrevious alias finding resolved in PerformanceNo findings. The conventions guard reads notebook JSON without executing notebook code. MaintainabilityNo findings. Configuration checks and workflow assertions cover the allowlist and CI wiring. Tech DebtNo findings requiring action. Existing violations and pending notebooks remain explicitly recorded as transitional exceptions. SecurityNo findings in the changed code or workflow commands. Documentation/TestsPrevious deletion finding resolved: both The new changelog fragment is present, and the repository’s fragment validator passes. Static validation passed as described above; numerical drift execution remains unverified locally. |
…paper does Tutorial convention 6 said neither the never-treated nor the not-yet-treated assumption is uniformly weaker. Callaway and Sant'Anna (2021) do not rank them; they say the not-yet-treated version additionally restricts pre-treatment trends across cohorts, and suggest never-treated when that group is sizeable. The convention now says that.
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: ✅ Looks goodBoth previous P2 findings remain resolved. No unmitigated P0 or P1 findings. Executive summary
MethodologyNo findings. No estimator, weighting, variance, or identification behavior changes. The guidance in Code QualityNo findings. The previous alias-handling issue remains resolved in PerformanceNo findings. The new guard parses notebook JSON without executing cells. The expanded workflow selects the existing drift modules and retains the default exclusion of slow tests. MaintainabilityNo findings. Configuration checks cover stale allowlist entries, prohibited exceptions, and drift-test mappings. Workflow assertions pin the added CI wiring. Tech DebtNo findings requiring action. Existing notebook violations and pending notebooks are explicitly recorded as transitional exceptions. SecurityNo findings in the changed code or workflow commands. Documentation/TestsNo findings requiring action. The new changelog fragment follows repository conventions, and both modified workflows parse successfully. Validation covers the static guard and changelog format; numerical drift results remain unverified locally. |
Summary
Second PR of the post-4.0 tutorial repair (the first is #905). It adds the convention and the guard; it edits no notebook. Each notebook is then repaired, re-executed and removed from the allowlist in one of six follow-up track PRs.
CONTRIBUTING.md- "Tutorial conventions". What every notebook states and how: an estimand-and-assumptions block before the first fit; a truth check on simulated data with the truth-determining generator arguments passed explicitly; unit-clustered inference and which p-values are count-based; pre-trend tests are never pass/fail; never-treated vs not-yet-treated as different assumptions; one event-study idiom; no unqualified warning suppression; a standard closing; reader voice (no migration narration, ledger ids, PR numbers orfile:linereferences); committed outputs; a drift test per notebook. Also the recipe for re-executing a notebook.tests/test_tutorial_conventions.py. Enforces the mechanical rules over everydocs/tutorials/*.ipynbby parsing the notebook JSON (nothing is executed): execution counts1..n, no committed error output, no removed 4.0 names (overall_att,MultiPeriodDiD,StaggeredTripleDifference) or removed classes/aliases used as code identifiers, no internal jargon, no unqualifiedfilterwarnings("ignore")/simplefilter("ignore")(call arguments inspected through the AST), no em dashes in sources, noHAS_MATPLOTLIBguard, exactly one drift test per notebook.KNOWN_VIOLATIONSrecords the rules each of 29 notebooks violates today. The guard fails on any unlisted violation and also when a listed one has been fixed, so a repair PR must delete its entries; the dict is meant to end empty. Error outputs can never be allowlisted.docs-tests.ymlruns the guard (its path filters already coverdocs/**; the test file's own path is added).notebooks.ymlnow runs everytests/test_t*_drift.pyinstead of only the two MMM ones, and triggers on drift-test changes: until now a notebook-only diff ran no lane that executes the drift tests (about 9 s on the pure-Python backend, slow-marked tests excluded). Both wirings are self-pinned in the new test file.docs/tutorials/README.mdis reduced to a pointer toindex.rstand the conventions (the old hand-maintained list omitted eleven notebooks, 05-14 and 28, and stated Python 3.8+).Convention 7 cites
tests/test_visualization.py::TestEventStudyIdiomContract, which is added by #905.Methodology references (required if estimator / math changes)
docs/methodology/REGISTRY.md(permutation test(c+1)/(B+1); SyntheticDiD placebomax(c/B, 1/(B+1))).Validation
tests/test_tutorial_conventions.py(new: one parametrized guard test per notebook, configuration consistency, rule fixtures, workflow pins).main; six are already clean (27-31, 34).Security / privacy
Changelog