You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address PR #105 feedback: fix Webb weights, lazy R fixture, test perf
- Fix Rust Webb bootstrap weights to match NumPy implementation:
- Correct values: ±√(3/2), ±1, ±√(1/2) (was using wrong values)
- Correct probabilities: [1,2,3,3,2,1]/12 (was uniform)
- Add 3 Rust unit tests for Webb weight verification
- Both backends now produce variance ≈ 0.833
- Add lazy R availability fixture to avoid import-time latency:
- New tests/conftest.py with session-scoped r_available fixture
- Support DIFF_DIFF_R=skip environment variable
- Test collection now completes in <1s (was ~2s with subprocess)
- Improve test performance:
- Add @pytest.mark.slow marker for thorough bootstrap tests
- Reduce bootstrap iterations from 199 to 99 where sufficient
- Add slow marker definition to pyproject.toml
- Documentation updates:
- METHODOLOGY_REVIEW.md: Correct Webb variance to 0.833
- TODO.md: Log 7 pre-existing NaN handling issues
- CLAUDE.md: Document Rust test troubleshooting (PyO3 linking)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,36 @@ DIFF_DIFF_BACKEND=rust pytest
53
53
pytest tests/test_rust_backend.py -v
54
54
```
55
55
56
+
#### Troubleshooting Rust Tests (PyO3 Linking)
57
+
58
+
If `cargo test` fails with `library 'pythonX.Y' not found`, PyO3 cannot find the Python library. This commonly happens on macOS when using the system Python (which lacks development headers in expected locations).
59
+
60
+
**Solution**: Use a Python environment with proper library paths (e.g., conda, Homebrew, or pyenv):
61
+
62
+
```bash
63
+
# Using miniconda (example path - adjust for your system)
64
+
cd rust
65
+
PYO3_PYTHON=/path/to/miniconda3/bin/python3 \
66
+
DYLD_LIBRARY_PATH="/path/to/miniconda3/lib" \
67
+
cargo test
68
+
69
+
# Using Homebrew Python
70
+
PYO3_PYTHON=/opt/homebrew/bin/python3 \
71
+
DYLD_LIBRARY_PATH="/opt/homebrew/lib" \
72
+
cargo test
73
+
```
74
+
75
+
**Environment variables:**
76
+
-`PYO3_PYTHON`: Path to Python interpreter with development headers
77
+
-`DYLD_LIBRARY_PATH` (macOS) / `LD_LIBRARY_PATH` (Linux): Path to `libpythonX.Y.dylib`/`.so`
78
+
79
+
**Verification**: All 22 Rust tests should pass, including bootstrap weight tests:
80
+
```
81
+
test bootstrap::tests::test_webb_variance_approx_correct ... ok
82
+
test bootstrap::tests::test_webb_values_correct ... ok
83
+
test bootstrap::tests::test_webb_mean_approx_zero ... ok
Copy file name to clipboardExpand all lines: TODO.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,28 @@ Target: < 1000 lines per module for maintainability.
52
52
|`pretrends.py`| 1160 | Acceptable |
53
53
|`bacon.py`| 1027 | OK |
54
54
55
+
### NaN Handling for Undefined t-statistics
56
+
57
+
Several estimators return `0.0` for t-statistic when SE is 0 or undefined. This is incorrect—a t-stat of 0 implies a null effect, whereas `np.nan` correctly indicates undefined inference.
58
+
59
+
**Pattern to fix**: `t_stat = effect / se if se > 0 else 0.0` → `t_stat = effect / se if se > 0 else np.nan`
60
+
61
+
| Location | Line | Current Code |
62
+
|----------|------|--------------|
63
+
|`diagnostics.py`| 665 |`t_stat = original_att / se if se > 0 else 0.0`|
64
+
|`diagnostics.py`| 786 |`t_stat = mean_effect / se if se > 0 else 0.0`|
0 commit comments