Commit 0266d59
Fix CI review R10: within-group-constant strata/PSU + sanitize SE helper
- P1 #1/#2: Add _validate_group_constant_strata_psu() helper and call
it from fit() after the weight_type/replicate-weights checks. The
dCDH IF expansion psi_i = U[g] * (w_i / W_g) treats each group as
the effective sampling unit; when strata or PSU vary within group it
silently spreads horizon-specific IF mass across observations in
different PSUs, contaminating the stratified-PSU variance. Walk back
the overstated claim at the old line 669 comment to match. Within-
group-varying weights remain supported.
- P1 #3: _survey_se_from_group_if now filters zero-weight rows before
np.unique/np.bincount so NaN / non-comparable group IDs on excluded
subpopulation rows cannot crash SE factorization. psi stays full-
length with zeros in excluded positions to preserve alignment with
resolved.strata / resolved.psu inside compute_survey_if_variance.
- REGISTRY.md line 652 Note updated: explicitly states the
within-group-constant strata/PSU requirement and the
within-group-varying weights support.
- Tests: new TestSurveyWithinGroupValidation class (4 tests — rejects
varying PSU, rejects varying strata, accepts varying weights, and
ignores zero-weight rows during the constancy check) plus
TestZeroWeightSubpopulation.test_zero_weight_row_with_nan_group_id.
All 268 targeted tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d045987 commit 0266d59
3 files changed
Lines changed: 185 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
669 | | - | |
670 | | - | |
671 | | - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
672 | 678 | | |
673 | 679 | | |
674 | 680 | | |
| |||
4696 | 4702 | | |
4697 | 4703 | | |
4698 | 4704 | | |
| 4705 | + | |
| 4706 | + | |
| 4707 | + | |
| 4708 | + | |
| 4709 | + | |
| 4710 | + | |
| 4711 | + | |
| 4712 | + | |
| 4713 | + | |
| 4714 | + | |
| 4715 | + | |
| 4716 | + | |
| 4717 | + | |
| 4718 | + | |
| 4719 | + | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
| 4723 | + | |
| 4724 | + | |
| 4725 | + | |
| 4726 | + | |
| 4727 | + | |
| 4728 | + | |
| 4729 | + | |
| 4730 | + | |
| 4731 | + | |
| 4732 | + | |
| 4733 | + | |
| 4734 | + | |
| 4735 | + | |
| 4736 | + | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
| 4742 | + | |
| 4743 | + | |
| 4744 | + | |
| 4745 | + | |
| 4746 | + | |
| 4747 | + | |
| 4748 | + | |
| 4749 | + | |
| 4750 | + | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
| 4754 | + | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
4699 | 4760 | | |
4700 | 4761 | | |
4701 | 4762 | | |
| |||
4762 | 4823 | | |
4763 | 4824 | | |
4764 | 4825 | | |
| 4826 | + | |
| 4827 | + | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
| 4831 | + | |
| 4832 | + | |
| 4833 | + | |
| 4834 | + | |
| 4835 | + | |
| 4836 | + | |
| 4837 | + | |
| 4838 | + | |
| 4839 | + | |
| 4840 | + | |
| 4841 | + | |
| 4842 | + | |
4765 | 4843 | | |
4766 | 4844 | | |
4767 | 4845 | | |
4768 | | - | |
4769 | | - | |
| 4846 | + | |
| 4847 | + | |
4770 | 4848 | | |
4771 | | - | |
4772 | | - | |
4773 | | - | |
4774 | | - | |
| 4849 | + | |
| 4850 | + | |
| 4851 | + | |
| 4852 | + | |
4775 | 4853 | | |
4776 | 4854 | | |
4777 | | - | |
4778 | | - | |
| 4855 | + | |
| 4856 | + | |
4779 | 4857 | | |
4780 | 4858 | | |
4781 | 4859 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
864 | 884 | | |
865 | 885 | | |
866 | 886 | | |
| |||
1010 | 1030 | | |
1011 | 1031 | | |
1012 | 1032 | | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
0 commit comments