Repository navigation
Conversation
…e_design DesignDiagnosisResults.lock records the pre-specified estimator as a JSON-serializable DesignLock; DesignLock.reconcile labels the analysis that was run pre-specified or deviates. With several estimators, diagnose_design holds the last periods out of the comparison (n_holdout) and lock() reruns only the chosen estimator with them. The data fingerprint now encodes numbers by value.
…and column labels equal as strings
Overall assessmentExecutive summary
MethodologyP3 — Documented library choices; no action required. Cross-checked Impact: The overlapping full-panel rerun, shorter comparison window, derived seed, binary label, and declaration-only checks are explicitly documented choices, not methodology defects. Concrete fix: None required. Code QualityP1 — Include estimator class in the diagnosis snapshot. The mutation guard compares only diagnosis.estimators["did"] = TwoWayFixedEffects()
lock = diagnosis.lock("did")The lock records Impact: Concrete fix: Snapshot each candidate’s class alongside its parameters at diagnosis time and reject either changing before constructing the lock. PerformanceNo material performance defect identified in the changed paths. MaintainabilityNo additional findings. Tech DebtP3 — Tutorial and report integration are properly tracked. Impact: The workflow currently exposes reconciliation through its own results object; integration into reports remains pending. Concrete fix: None required in this PR; retain the tracked release commitments. SecurityNo security finding identified. Estimator reconstruction uses an explicit supported-class allowlist; the hash’s accident-detection purpose is documented. Documentation/TestsThe required fragment exists at Changed Python files passed syntax parsing. Full behavioral and numerical tests remain unverified locally because their dependencies are unavailable. Path to Approval
|
Summary
Second part of design diagnosis (follows #898, no release in between).
diagnose_designcompares candidate estimators on an untreated panel; this PR carries the choice into the analysis.diagnose_designnow leaves the last periods of the panel out of the comparison (newn_holdout=; default half of the periods at or after the latest adoption period, rounded down; an error namingn_holdout=0if that is zero). The held-out rows are removed by period value before any outcome is validated, fingerprinted or fitted.DesignDiagnosisResults.lock(label, data=)records one estimator as the pre-specified choice. When periods were held out it reruns that estimator alone with them included, at the declared adoption dates, with a seed derived from the recorded one, and reports that run. It refuses a panel whose periods or fingerprint differ from the diagnosed one, a configuration changed after the diagnosis, and a configuration that cannot be rebuilt from JSON.DesignLock(frozen, plain JSON data): chosen estimator and configuration, declared design, panel fingerprint and period values, the comparison rows of every estimator compared, the chosen estimator's reported rows, size check and MDE, library and schema version (DESIGN_LOCK_SCHEMA_VERSION = "1.0"), and asha256of its canonical JSON.to_json()/from_json()/to_dict()/from_dict(),to_estimator(),to_dataframe(),summary().DesignLock.reconcile(estimator, outcome=, unit=, time=, ...)returns aDesignReconciliationResults: one check per item and the labelpre-specifiedordeviates. Always: estimator class, every constructor parameter,fit()keywords, column names. Withresults=:alpha. Withdata=: fingerprint of the diagnosed periods, unit count, panel balance, treated count, cohort count and per-cohort post-window length.data_sha256now encodes numbers by value (1and1.0are the same cell), so the digest of a set of rows does not change when pandas stores an integer column as float because another row is missing.diagnose_designis unreleased, so no stored fingerprint is affected.Not in this PR (tracked in
TODO.md): wiring the label intoDiagnosticReport/BusinessReport, and the "Study Design" tutorial. Both ship before the release that carriesdiagnose_design.Methodology references (required if estimator / math changes)
docs/methodology/REGISTRY.md## DesignDiagnosis). No estimator formula, weighting or variance computation changes.- **Note:**entries in the registry: held-out periods and their default count; the lock run using the full panel at the declared dates (it overlaps the comparison data, and the comparison runs on a shorter post window); the derived lock seed; the binary label with no grading, covering only the listed checks;reconcileas a declaration check (fitted results do not record their configuration, so a parameter changed withset_params()after fitting cannot be detected); realized timing reconciled through cohort count, treated count, post-window lengths and panel balance, not adoption dates; the lock hash as accident detection, not a signature; refusal of configurations that are not JSON data or not finite. How much selection inflation the held-out rerun removes is not validated numerically, and the registry says so.Validation
tests/test_design.py(newTestHoldout,TestLock,TestLockSerialization,TestToEstimator,TestReconcile; 174 tests in the file),tests/test_methodology_design.py(newTestHeldOutRun; 17 tests),tests/test_naming_guard.py,tests/test_diagnostic_marker.py,tests/helpers/results_foundation.py.-Wbuild passes.Security / privacy
Changelog