Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import pytest


# =============================================================================
# R Availability Fixtures (Lazy Loading)
# =============================================================================
Expand Down
14 changes: 12 additions & 2 deletions tests/test_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ def test_alias_identity():
def test_aliases_in_all():
"""All aliases are listed in __all__."""
aliases = [
"DiD", "TWFE", "EventStudy", "SDiD", "CS", "CDiD",
"SA", "BJS", "Gardner", "DDD", "Stacked", "Bacon",
"DiD",
"TWFE",
"EventStudy",
"SDiD",
"CS",
"CDiD",
"SA",
"BJS",
"Gardner",
"DDD",
"Stacked",
"Bacon",
]
for alias in aliases:
assert alias in diff_diff.__all__, f"{alias} missing from __all__"
Expand Down
17 changes: 6 additions & 11 deletions tests/test_bandwidth_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def golden():
not copied alongside tests/)."""
if not GOLDEN_PATH.exists():
pytest.skip(
"Golden values file not found; "
"run: Rscript benchmarks/R/generate_nprobust_golden.R"
"Golden values file not found; " "run: Rscript benchmarks/R/generate_nprobust_golden.R"
)
with GOLDEN_PATH.open() as f:
return json.load(f)
Expand Down Expand Up @@ -139,9 +138,9 @@ def test_R_parity(self, dgp_case, stage):
if expected == 0:
assert actual == pytest.approx(0, abs=1e-10), f"{name} {stage}"
else:
assert actual == pytest.approx(expected, rel=_PARITY_TOL), (
f"{name} {stage}: py={actual!r} R={expected!r}"
)
assert actual == pytest.approx(
expected, rel=_PARITY_TOL
), f"{name} {stage}: py={actual!r} R={expected!r}"


# =============================================================================
Expand Down Expand Up @@ -257,9 +256,7 @@ def test_public_wrapper_fixes_vce_nn_nnmatch_3(self):
G = 2000
d = rng.uniform(0, 1, size=G)
y = d + d**2 + rng.normal(0, 0.5, size=G)
via_wrapper = mse_optimal_bandwidth(
d, y, kernel="epanechnikov", return_diagnostics=True
)
via_wrapper = mse_optimal_bandwidth(d, y, kernel="epanechnikov", return_diagnostics=True)
via_port_nn = lpbwselect_mse_dpi(
y,
d,
Expand Down Expand Up @@ -477,9 +474,7 @@ def test_wrapper_rank_deficient_raises_valueerror(self):
# 0.3, 0.4). The B1 design matrix has o_B+1 = 5 columns but
# only 4 independent rows -> rank-deficient X'X -> Cholesky
# fails in qrXXinv.
d = np.concatenate(
[[0.1], np.full(50, 0.15), np.full(50, 0.3), np.full(50, 0.4)]
)
d = np.concatenate([[0.1], np.full(50, 0.15), np.full(50, 0.3), np.full(50, 0.4)])
y = d + rng.normal(0, 0.01, size=d.size)
with pytest.raises(ValueError, match="qrXXinv"):
mse_optimal_bandwidth(d, y, boundary=float(d.min()))
Expand Down
190 changes: 74 additions & 116 deletions tests/test_bias_corrected_lprobust.py

Large diffs are not rendered by default.

Loading
Loading