Commit 657b62b
Fix CI review R12: preserve full survey design under auto-inject
R11's auto-inject of psu=group filtered `data` to positive-weight rows
before re-resolving the effective SurveyDesign. That silently shrank
`df_survey` on SurveyDesign.subpopulation() inputs without an explicit
PSU — violating the documented subpopulation contract that keeps the
full design intact so t critical values, p-values, CIs, and HonestDiD
bounds match full-design expectations.
Replace the pre-filter with a synthesized PSU column built on a
private copy of `data`:
- Valid group values flow through unchanged as the per-row PSU label.
- NaN / invalid group values on zero-weight rows (the edge case that
motivated the R11 filter) are replaced with a single shared dummy
label so the PSU resolver accepts them.
- Zero-weight rows contribute psi_i = 0 to the variance, but remain in
the resolved design so n_psu / n_strata / df_survey reflect the
full sample — matching the library's subpopulation contract.
Added TestSurveyWithinGroupValidation.test_subpopulation_preserves_full_design_df_survey:
zero-weights an entire group (mimicking SurveyDesign.subpopulation)
and asserts that auto-inject df_survey equals the explicit psu='group'
df_survey — the full-design reference.
All 271 targeted tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bfee956 commit 657b62b
2 files changed
Lines changed: 63 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
682 | 696 | | |
683 | 697 | | |
684 | 698 | | |
685 | 699 | | |
686 | | - | |
| 700 | + | |
687 | 701 | | |
688 | 702 | | |
689 | 703 | | |
690 | 704 | | |
691 | 705 | | |
692 | 706 | | |
693 | | - | |
| 707 | + | |
694 | 708 | | |
695 | 709 | | |
696 | 710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
1120 | 1160 | | |
1121 | 1161 | | |
1122 | 1162 | | |
| |||
0 commit comments