Skip to content

Commit 6785d6a

Browse files
igerberclaude
andcommitted
Address PR #378 R4 P3: rename test to reflect actual scope
Test name `test_single_baseline_heterogeneous_F_g_no_warning_and_matches_r` oversold its scope — the body only checks warning suppression and finite effects. The numeric R-parity assertion (rtol ~1e-11 per-path) lives in TestDCDHDynRParityByPathControls which fits the same scenario and compares against the golden values. Renamed to `test_single_baseline_heterogeneous_F_g_does_not_warn` and updated docstring + inline comment to spell out: this test locks the warning-suppression invariant; the numeric R-parity check is in the parity test class. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fb7a912 commit 6785d6a

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

tests/test_chaisemartin_dhaultfoeuille.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6660,16 +6660,16 @@ def test_single_baseline_panel_does_not_emit_r_deviation_warning(self):
66606660
f"panel: {deviation_msgs}"
66616661
)
66626662

6663-
def test_single_baseline_heterogeneous_F_g_no_warning_and_matches_r(self):
6664-
"""Pin the precise parity condition: single-baseline switcher
6665-
panel with HETEROGENEOUS ``F_g`` across paths produces (a) no
6666-
multi-baseline UserWarning and (b) per-path point estimates that
6667-
match R bit-exactly. Uses the
6663+
def test_single_baseline_heterogeneous_F_g_does_not_warn(self):
6664+
"""Pin the precise warning condition: single-baseline switcher
6665+
panel with HETEROGENEOUS ``F_g`` across paths must NOT trigger
6666+
the multi-baseline R-deviation warning, and the fit must
6667+
produce finite per-path effects. Uses the
66686668
``multi_path_reversible_by_path_controls`` golden-value scenario,
66696669
whose switchers all share ``D_{g,1}=0`` while ``F_g`` spans
66706670
[0..6] across 4 distinct observed paths.
66716671
6672-
Why this is the right parity condition (not just a global
6672+
Why this is the right warning condition (not just a global
66736673
baseline check): R's per-path subset
66746674
(``R/R/did_multiplegt_dyn.R`` lines 401-405) includes
66756675
``yet_to_switch=1`` rows with matching baseline regardless of
@@ -6678,7 +6678,17 @@ def test_single_baseline_heterogeneous_F_g_no_warning_and_matches_r(self):
66786678
switchers with matching baseline + all rows of never-switchers
66796679
with matching baseline) — bit-identical to our global first-
66806680
stage sample under single-baseline conditions, even when ``F_g``
6681-
and path identity vary across switchers."""
6681+
and path identity vary across switchers.
6682+
6683+
The actual numeric R-parity assertion (rtol ~1e-11 on per-path
6684+
point estimates) lives in
6685+
``tests/test_chaisemartin_dhaultfoeuille_parity.py::TestDCDHDynRParityByPathControls::test_parity_multi_path_reversible_by_path_controls``,
6686+
which fits the same scenario and compares cell-by-cell against
6687+
the R-generated golden values. This test deliberately does NOT
6688+
duplicate that numeric check; it locks the warning-suppression
6689+
invariant on the same fixture so future changes to either the
6690+
warning predicate or the parity scenario keep both surfaces
6691+
coherent."""
66826692
data = _load_by_path_controls_scenario()
66836693

66846694
# Sanity: panel has multiple distinct switcher F_g values but a
@@ -6732,12 +6742,12 @@ def test_single_baseline_heterogeneous_F_g_no_warning_and_matches_r(self):
67326742
"heterogeneity), so this scenario must NOT trigger the warning."
67336743
)
67346744

6735-
# Locked numeric checks: per-path point estimates from this fit
6736-
# match the R `did_multiplegt_dyn(..., by_path=3, controls="X1")`
6737-
# output to rtol ~1e-11 on this scenario (the parity test in
6738-
# `test_chaisemartin_dhaultfoeuille_parity.py::TestDCDHDynRParityByPathControls`
6739-
# asserts this against the golden values; here we lock the
6740-
# internal-only invariant that the estimates are produced).
6745+
# Lock the local invariant that the fit produces non-empty
6746+
# finite per-path estimates on this scenario. The numeric R-
6747+
# parity assertion (per-path point estimates within rtol ~1e-11
6748+
# of R) is locked separately in
6749+
# `tests/test_chaisemartin_dhaultfoeuille_parity.py::TestDCDHDynRParityByPathControls`
6750+
# against the golden values.
67416751
assert res.path_effects is not None and len(res.path_effects) >= 1
67426752
for path, entry in res.path_effects.items():
67436753
for l_h, vals in entry["horizons"].items():

0 commit comments

Comments
 (0)