Skip to content

Commit 7277ec8

Browse files
igerberclaude
andcommitted
Extend mse_optimal_bandwidth Raises docstring (P3)
CI AI review P3: the docstring only listed shape/finite/kernel/weights raises but the implementation now also raises on boundary off-support, mass-point, bwcheck out-of-range, and per-stage rank/count failures. Document the full contract. 175 tests pass (unchanged). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8d357b6 commit 7277ec8

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

diff_diff/local_linear.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,20 @@ def mse_optimal_bandwidth(
564564
Raises
565565
------
566566
ValueError
567-
If shapes mismatch, inputs are non-finite, or ``kernel`` is
568-
unknown.
567+
Raised on: shape mismatch between ``d`` and ``y``; non-finite
568+
values in ``d``, ``y``, or ``boundary``; unknown ``kernel``
569+
name; ``bwcheck`` outside ``[1, len(d)]``; ``boundary`` that
570+
is not approximately 0 or approximately ``d.min()`` (the only
571+
two supported HAD estimands in Phase 1b); or a rank-deficient
572+
/ under-determined pilot fit inside the DPI port (surfaced
573+
from ``qrXXinv`` or the per-stage count guards in
574+
``lprobust_bw``).
569575
NotImplementedError
570-
If ``weights`` is passed (see parameter note).
576+
Raised on: ``weights=`` passed (no nprobust parity anchor);
577+
detected Design 1 mass-point design (``d.min() > 0`` and
578+
modal fraction at ``d.min()`` exceeds 2%, per the paper's
579+
Section 3.2.4 redirection to the 2SLS sample-average
580+
estimator, queued for Phase 2).
571581
572582
Notes
573583
-----

0 commit comments

Comments
 (0)