Commit ca7b6bf
Narrow auto-inject guard to nest=False + regression test for nest=True
The previous round's guard fired on any varying-strata + omitted-psu
combination, which rejected `SurveyDesign(weights, strata, nest=True)`
unnecessarily. `SurveyDesign.resolve()` at `diff_diff/survey.py:299-302`
combines `(stratum, psu)` into globally-unique labels under nest=True,
so the auto-injected `psu=<group>` is re-labeled per stratum and the
cross-stratum uniqueness check passes. Only the `nest=False` default
path actually needs the up-front guard.
Narrows the guard to `not getattr(survey_design, "nest", False)` and
updates the error message to enumerate three actionable remediations
(constant-within-group strata, or `nest=True`, or explicit `psu`).
Adds `test_auto_inject_with_varying_strata_nest_true_succeeds` under
`TestSurveyWithinGroupValidation` covering the newly-accepted path:
byte-for-byte match against explicit `SurveyDesign(weights, strata,
psu="group", nest=True)` on `overall_se` and `survey_metadata.df_survey`.
The default `nest=False` still-raises regression
(`test_auto_inject_with_varying_strata_raises`) remains unchanged.
Updates fit() docstring and the REGISTRY.md survey IF expansion Note
to enumerate the three supported auto-inject paths: (1) strata constant
within group, (2) strata vary + nest=True, (3) strata vary + nest=False
(rejected with targeted ValueError).
All 338 tests pass (affected surface + slow MC coverage sim).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent dedc2a6 commit ca7b6bf
3 files changed
Lines changed: 80 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | | - | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
654 | 662 | | |
655 | 663 | | |
656 | 664 | | |
| |||
726 | 734 | | |
727 | 735 | | |
728 | 736 | | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
740 | 753 | | |
741 | 754 | | |
742 | 755 | | |
743 | 756 | | |
744 | 757 | | |
745 | 758 | | |
746 | 759 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
759 | 774 | | |
760 | 775 | | |
761 | 776 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
| 652 | + | |
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1172 | 1172 | | |
1173 | 1173 | | |
1174 | 1174 | | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
1175 | 1215 | | |
1176 | 1216 | | |
1177 | 1217 | | |
| |||
0 commit comments