Skip to content

Commit 4e24cac

Browse files
igerberclaude
andcommitted
Fix CI failure: cast treatment to float before injecting non-integer D in test
`tests/test_chaisemartin_dhaultfoeuille.py::TestByPathNonBinary::test_non_integer_D_raises` failed across all 7 CI runners (macos py3.11/3.14, ubuntu-24.04-arm py3.11/3.13/3.14, ubuntu-latest py3.14, windows-latest py3.11) with: TypeError: Invalid value '1.5' for dtype 'int64' The fixture builds `df["treatment"]` as integers in {0, 1, 2}, so the column dtype is int64. On pandas >= 2.x (the version pinned in CI for py3.11+ runners), `df.loc[mask, "treatment"] = 1.5` raises TypeError outright; on older pandas (the local dev env) it emitted a FutureWarning and proceeded. The test path was supposed to exercise the estimator's D-integer guard at fit-time, not pandas's dtype coercion behavior. Cast `df["treatment"]` to float before injecting 1.5 so the test behaves identically across pandas versions and reaches the ValueError raise it was written to verify. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f97ab76 commit 4e24cac

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/test_chaisemartin_dhaultfoeuille.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8208,7 +8208,12 @@ def test_no_longer_raises_on_non_binary(self):
82088208
def test_non_integer_D_raises(self):
82098209
"""D values containing 1.5 raise ValueError."""
82108210
df = _by_path_data_with_non_binary_treatment()
8211-
# Inject a non-integer D for one cell
8211+
# Cast `treatment` to float BEFORE assigning 1.5: on pandas >= 2.x
8212+
# `df.loc[mask, "treatment"] = 1.5` raises `TypeError: Invalid
8213+
# value '1.5' for dtype 'int64'` outright instead of silently
8214+
# coercing. We want to inject a continuous value to test the
8215+
# estimator's D-integer guard, not exercise pandas dtype coercion.
8216+
df["treatment"] = df["treatment"].astype(float)
82128217
mask = (df["group"] == 0) & (df["period"] == 4)
82138218
df.loc[mask, "treatment"] = 1.5
82148219
est = ChaisemartinDHaultfoeuille(

0 commit comments

Comments
 (0)