Skip to content

Commit 79f428d

Browse files
committed
efficient-did: complete cluster_name rename propagation + suppress duplicate Bootstrap summary line
Two follow-up fixes: 1. cluster → cluster_name propagation. The original PR renamed the EfficientDiDResults.cluster field to cluster_name but left two consumers still referencing the old name: - tests/test_business_report.py:1267 (TestHausmanPretestPropagatesCluster regression test asserting the field is persisted for the Hausman pretest replay) — updated assertion + class docstring. - docs/api/_autosummary/diff_diff.EfficientDiDResults.rst — the checked-in Sphinx autosummary still listed cluster and was missing cluster_name, n_clusters, vcov_type, and the new to_dict() method. 2. Suppress duplicate Bootstrap summary header. EfficientDiDResults.summary() previously emitted both the legacy "Bootstrap: <n> (<weights>)" header line (L250-L251 pre-PR) and the new "Inference method: bootstrap" + "Bootstrap replications: <n>" block. The legacy header is now gated on `bootstrap_results is None` so analytical-only fits keep the original render and bootstrap-overwritten fits use the canonical inference-method block alone (matches the sibling result-container convention). 211 tests pass across test_efficient_did.py, test_efficient_did_validation.py, test_diagnostics.py, and test_business_report.py::TestHausmanPretestPropagatesCluster. black + ruff clean on touched Python files.
1 parent 64cc8a2 commit 79f428d

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

diff_diff/efficient_did_results.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ def summary(self, alpha: Optional[float] = None) -> str:
247247
lines.append(f"{'Control group:':<30} {self.control_group:>10}")
248248
if self.anticipation > 0:
249249
lines.append(f"{'Anticipation periods:':<30} {self.anticipation:>10}")
250-
if self.n_bootstrap > 0:
250+
# Suppress the legacy ``Bootstrap:`` header when ``bootstrap_results``
251+
# is present — the new variance/inference-method block below renders
252+
# the canonical ``Inference method: bootstrap`` + ``Bootstrap
253+
# replications:`` lines, so the old header would duplicate metadata.
254+
if self.n_bootstrap > 0 and self.bootstrap_results is None:
251255
lines.append(f"{'Bootstrap:':<30} {self.n_bootstrap:>10} ({self.bootstrap_weights})")
252256
lines.append("")
253257

docs/api/_autosummary/diff_diff.EfficientDiDResults.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
~EfficientDiDResults.print_summary
1616
~EfficientDiDResults.summary
1717
~EfficientDiDResults.to_dataframe
18+
~EfficientDiDResults.to_dict
1819

1920

2021

@@ -28,7 +29,7 @@
2829
~EfficientDiDResults.att
2930
~EfficientDiDResults.bootstrap_results
3031
~EfficientDiDResults.bootstrap_weights
31-
~EfficientDiDResults.cluster
32+
~EfficientDiDResults.cluster_name
3233
~EfficientDiDResults.coef_var
3334
~EfficientDiDResults.conf_int
3435
~EfficientDiDResults.control_group
@@ -40,6 +41,7 @@
4041
~EfficientDiDResults.is_significant
4142
~EfficientDiDResults.kernel_bandwidth
4243
~EfficientDiDResults.n_bootstrap
44+
~EfficientDiDResults.n_clusters
4345
~EfficientDiDResults.omega_condition_numbers
4446
~EfficientDiDResults.p_value
4547
~EfficientDiDResults.pt_assumption
@@ -51,6 +53,7 @@
5153
~EfficientDiDResults.significance_stars
5254
~EfficientDiDResults.survey_metadata
5355
~EfficientDiDResults.t_stat
56+
~EfficientDiDResults.vcov_type
5457
~EfficientDiDResults.group_time_effects
5558
~EfficientDiDResults.overall_att
5659
~EfficientDiDResults.overall_se

tests/test_business_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ def test_survey_weighted_fit_skipped_with_reason(self):
12421242

12431243
class TestHausmanPretestPropagatesCluster:
12441244
"""Round-11 regression: ``EfficientDiDResults`` now persists the
1245-
``cluster`` column used at fit time, and ``_pt_hausman`` forwards
1245+
``cluster_name`` column used at fit time, and ``_pt_hausman`` forwards
12461246
it to ``EfficientDiD.hausman_pretest``. Without this, clustered
12471247
fits would be replayed under unclustered inference, silently
12481248
publishing an H statistic / p-value for the wrong design.
@@ -1266,7 +1266,7 @@ def test_hausman_pretest_receives_cluster_kwarg(self):
12661266
first_treat="first_treat",
12671267
)
12681268
# Confirm persistence landed.
1269-
assert getattr(edid, "cluster", None) == "cluster_col"
1269+
assert getattr(edid, "cluster_name", None) == "cluster_col"
12701270

12711271
captured: dict = {}
12721272

0 commit comments

Comments
 (0)