fix: NumPy 2 compatibility — replace removed np.row_stack/np.column_stack - #16
Conversation
np.row_stack and np.column_stack were removed in NumPy 2.0. Replace with their equivalents np.vstack and np.hstack. Also update CI to test on Python 3.12.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e93ac6e584
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| channel_first=np.row_stack, | ||
| channel_last=np.column_stack, | ||
| channel_first=np.vstack, | ||
| channel_last=np.hstack, |
There was a problem hiding this comment.
Restore 2-D channel_last stacking
When feature_format="channel_last", the four feature arrays passed below are 1-D, and np.hstack concatenates 1-D inputs into a single (4 * feature_len,) vector. The previous np.column_stack produced the documented (feature_len, 4) shape, so this makes channel_last indistinguishable from flat and can break or silently mis-shape consumers expecting time-major channels; use an equivalent column-wise stack such as np.stack(..., axis=-1) instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR aims to restore compatibility with NumPy 2 by replacing APIs reported as removed (np.row_stack/np.column_stack) and extends the GitHub Actions formatting workflow matrix to include Python 3.12.
Changes:
- Replaced
np.row_stackwithnp.vstackin feature formatting logic. - Replaced
np.column_stackwithnp.hstackin feature formatting logic. - Updated the formatting workflow Python matrix to run on Python 3.10–3.12.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pcg_springer_features/springer_features.py | Updates feature stacking functions for NumPy 2 compatibility. |
| .github/workflows/check-formatting.yml | Updates CI matrix to include Python 3.12. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| strategy: | ||
| matrix: | ||
| python-version: ["3.8", "3.11"] | ||
| python-version: ["3.10", "3.11", "3.12"] |
np.hstack flattens 1-D inputs, making channel_last identical to flat. Use np.vstack(...).T to match the original column_stack behavior.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #16 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 137 137
=========================================
Hits 137 137 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
np.row_stackandnp.column_stackwere removed in NumPy 2. Replace them with their equivalentsnp.vstackandnp.hstack(drop-in replacements, identical behavior).Why
Tests fail on NumPy ≥2.5 with: