Remove numpy<2.4 pin now that pytensor fix is released#781
Remove numpy<2.4 pin now that pytensor fix is released#781drbenvincent merged 12 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #781 +/- ##
==========================================
+ Coverage 94.26% 94.42% +0.15%
==========================================
Files 78 78
Lines 12005 12061 +56
Branches 699 699
==========================================
+ Hits 11317 11389 +72
+ Misses 496 484 -12
+ Partials 192 188 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Require pytensor>=2.38.1 so installs include the einsum compatibility fix for numpy 2.4+ tracked in issue #723. Made-with: Cursor
Normalize singleton xarray/numpy values before float conversion in reporting stats so summary generation and notebook rendering no longer fail under newer NumPy behavior. Made-with: Cursor
Convert singleton array outputs to scalars before passing annotation coordinates to Matplotlib so notebook rendering works with NumPy 2.4+. Made-with: Cursor
Keep singleton-to-scalar normalization in scalar effect summary paths while leaving the time-series summary code unchanged to avoid unnecessary patch-scope churn. Made-with: Cursor
Use compact singleton-array to scalar coercion helpers in reporting and DiD plotting paths so NumPy 2.4 compatibility stays intact while reducing uncovered patch lines. Made-with: Cursor
Route xarray-derived scalar outputs through the shared coercion helper in time-series summaries and add regression tests for singleton-dimension paths to keep NumPy 2.4+ compatible behavior stable. Made-with: Cursor
3f0cc2a to
f85954e
Compare
Avoid unnecessary .values conversion in reporting paths and extend singleton scalar tests so NumPy 2.4+ behavior is handled at clear output boundaries. Made-with: Cursor
Cover DataArray HDI and OLS xarray extraction branches in reporting helpers so patch coverage reflects the NumPy-compatibility paths exercised in CI. Made-with: Cursor
Move the scalar-conversion helper to causalpy.utils so both reporting.py and diff_in_diff.py share a single implementation, as suggested in PR review. Made-with: Cursor
|
bugbot review |
PR SummaryMedium Risk Overview Hardens reporting and DiD plotting against NumPy 2.4’s stricter scalar conversion by introducing Adds regression tests covering singleton-array/DataArray scalar extraction, singleton Written by Cursor Bugbot for commit f812477. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Convert remaining float(x.values) patterns to _as_scalar() in interrupted_time_series.py and piecewise_its.py for consistency with the hardening already applied to reporting.py and diff_in_diff.py. Made-with: Cursor
|
All review feedback and the Bugbot suggestion have been addressed. Just needs green CI on the latest commit ( |
I already addressed the changes
Summary
numpy<2.4upper bound and requirepytensor>=2.38.1, now that the upstream NumPy 2.4 compatibility fix is availableenvironment.ymlaligned withpyproject.tomlfor these dependency requirementsWhy this change
TypeError: only 0-dimensional arrays can be converted to Python scalars)Files changed
pyproject.tomlenvironment.ymlcausalpy/reporting.pycausalpy/experiments/diff_in_diff.pycausalpy/tests/test_reporting.pyTest plan
$CONDA_EXE run -n CausalPy prek run --all-files$CONDA_EXE run -n CausalPy pytest causalpy/tests/test_reporting.py -q --no-cov$CONDA_EXE run -n CausalPy pytest causalpy/tests/test_integration_skl_examples.py::test_did causalpy/tests/test_integration_pymc_examples.py::test_did -q --no-covFixes #723.