Skip to content

Commit 1a20c16

Browse files
igerberclaude
andcommitted
Document R7 P1 + R8 P1 fit-time guards in SyntheticDiD.fit() docstring
The ``Raises`` section of ``SyntheticDiD.fit()`` previously only listed "non-pweight survey design" among its ``ValueError`` conditions. The two fit-time guards added in PR #355 R7 and R8 are not reflected in the docstring: - R7 P1: zero total survey mass on either arm. - R8 P1: ``fpc`` declared without explicit ``psu=`` where ``fpc`` is below the (per-stratum) unit count. Both raise ``ValueError`` before the bootstrap loop is dispatched. Expanding the ``Raises`` section makes the contract explicit to readers (and AI reviewers) cross-referencing the documented behavior against the implementation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f60ece2 commit 1a20c16

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

diff_diff/synthetic_did.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,21 @@ def fit( # type: ignore[override]
270270
------
271271
ValueError
272272
If required parameters are missing, data validation fails,
273-
or a non-pweight survey design is provided.
273+
or a non-pweight survey design is provided. Under survey
274+
designs, also raises when:
275+
276+
- The total survey mass on either arm is zero
277+
(``w_control.sum() == 0`` or ``w_treated.sum() == 0``).
278+
Every unit on that arm would have weight 0, encoding an
279+
unidentified target population (PR #355 R7 P1).
280+
- ``survey_design`` declares ``fpc`` with no explicit
281+
``psu=``. SDID Rao-Wu then treats each unit as its own
282+
PSU, so ``fpc`` must be ``>=`` the number of units
283+
(unstratified) or ``>=`` the per-stratum unit count
284+
(stratified). Front-door checked after
285+
``collapse_survey_to_unit_level`` so the user sees a
286+
targeted error instead of a bootstrap-exhaustion
287+
failure (PR #355 R8 P1).
274288
NotImplementedError
275289
If ``survey_design`` with strata/PSU/FPC is provided with
276290
``variance_method='placebo'`` or ``'jackknife'``. Bootstrap

0 commit comments

Comments
 (0)