Commit f60ece2
Address PR #355 R8 P1: front-door FPC validation for implicit-PSU SDID bootstrap
When ``SurveyDesign(fpc=...)`` is declared without an explicit
``psu=``, ``bootstrap_utils.generate_rao_wu_weights`` (L654-L655)
treats each unit as its own PSU. The helper rejects
``FPC < n_PSU`` mid-draw (L684-L688), so if FPC is set lower than the
unit count (per stratum if stratified), every bootstrap draw raises
ValueError; ``_bootstrap_se`` swallows the error in its retry loop and
the user eventually sees a generic bootstrap-exhaustion message
instead of a targeted FPC/design error.
Add a front-door validation on ``resolved_survey_unit`` after
``collapse_survey_to_unit_level``:
- unstratified: fpc >= total unit count;
- stratified: fpc_h >= per-stratum unit count.
Error messages point at the two actionable fixes (declare an
explicit psu= column, or raise FPC).
Two regression tests added:
``test_fit_raises_on_implicit_psu_fpc_below_unit_count_unstratified``
and ``test_fit_raises_on_implicit_psu_fpc_below_stratum_unit_count``.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5515fbe commit f60ece2
2 files changed
Lines changed: 92 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
442 | 483 | | |
443 | 484 | | |
444 | 485 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
912 | 963 | | |
913 | 964 | | |
914 | 965 | | |
| |||
0 commit comments