Skip to content

fix: NumPy 2 compatibility — replace removed np.row_stack/np.column_stack - #16

Merged
wenh06 merged 3 commits into
masterfrom
fix/numpy2-compat
Aug 1, 2026
Merged

fix: NumPy 2 compatibility — replace removed np.row_stack/np.column_stack#16
wenh06 merged 3 commits into
masterfrom
fix/numpy2-compat

Conversation

@wenh06

@wenh06 wenh06 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • np.row_stack and np.column_stack were removed in NumPy 2. Replace them with their equivalents np.vstack and np.hstack (drop-in replacements, identical behavior).
  • Update CI matrix to include Python 3.12.

Why

Tests fail on NumPy ≥2.5 with:

AttributeError: module 'numpy' has no attribute 'row_stack'

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.
Copilot AI review requested due to automatic review settings August 1, 2026 09:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_stack with np.vstack in feature formatting logic.
  • Replaced np.column_stack with np.hstack in 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.

Comment thread pcg_springer_features/springer_features.py Outdated
Comment thread .github/workflows/check-formatting.yml Outdated
strategy:
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
wenh06 and others added 2 commits August 1, 2026 17:06
np.hstack flattens 1-D inputs, making channel_last identical to flat.
Use np.vstack(...).T to match the original column_stack behavior.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3cf683c) to head (ca238ad).
⚠️ Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wenh06
wenh06 merged commit ebfb197 into master Aug 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants