Skip to content

Avoid deprecated assign to ndarray.shape#8020

Merged
stefanv merged 22 commits intoscikit-image:mainfrom
lagru:upd-deprecated-shape-assign
Mar 5, 2026
Merged

Avoid deprecated assign to ndarray.shape#8020
stefanv merged 22 commits intoscikit-image:mainfrom
lagru:upd-deprecated-shape-assign

Conversation

@lagru
Copy link
Copy Markdown
Member

@lagru lagru commented Jan 13, 2026

Description

Closes #8019, closes #8025. Still testing locally because there's no way to trigger the failing nightly job directly – it will run once merged into main though.

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

...

@lagru lagru added the 🔧 type: Maintenance Refactoring and maintenance of internals label Jan 13, 2026
@lagru lagru changed the title Upd deprecated shape assign Avoid deprecated assign to ndarray.shape Jan 13, 2026
@lagru
Copy link
Copy Markdown
Member Author

lagru commented Jan 14, 2026

@stefanv, as I said on Zulip, feel very welcome to take over this PR. :) I'm focusing on the typing stuff this week.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 21, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Updated dependency constraints across multiple manifests, removed the Meson include-v2 option and unconditionally include skimage2 in the build, and replaced deprecated in-place NumPy shape assignments with explicit np.reshape(..., copy=False) calls and related comment/docstring updates.

Changes

Cohort / File(s) Summary
Dependency Version Updates
environment.yml, pyproject.toml, requirements/default.txt, requirements/docs.txt, requirements/optional.txt, requirements/optional_free_threaded.txt
Bumped minimum versions for core and optional packages (notably numpy → >=2.1, scipy → >=1.14, tifffile → >=2025.1.10, matplotlib → >=3.10, dask → >=2025.1.0, scikit-learn → >=1.6, PyWavelets → >=1.7, astropy → >=6.1). Adjusted docs/test warning filters and removed a cibuildwheel setup-args entry.
Build Configuration
meson.options, src/meson.build
Removed the Meson boolean option include-v2 and its runtime conditional; skimage2 subdirectory is now added unconditionally to the build.
Array reshape migrations (NumPy 2.5 compatibility)
src/skimage/io/_plugins/pil_plugin.py, src/skimage/measure/_marching_cubes_lewiner.py, src/skimage/morphology/grayreconstruct.py, src/skimage/util/_map_array.py
Replaced assignments to array.shape = ... with np.reshape(..., copy=False) to avoid deprecated in-place shape mutation while preserving view/no-copy semantics.
Comments / Docstrings
src/skimage/feature/sift.py, src/skimage/graph/_mcp.pyx, src/skimage/restoration/_rolling_ball_cy.pyx
Updated inline comments and docstrings to describe reshape/view semantics (reflecting the change from direct shape assignment to np.reshape(..., copy=False)).
CI / Workflow
.github/workflows/test-pyodide.yaml
Updated Pyodide versions in the workflow matrix (PYODIDE_VERSION and PYODIDE_BUILD_VERSION).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive While most changes directly address the linked issues (shape assignment replacements) and related compatibility, the pull request includes substantial out-of-scope changes: broad dependency version upgrades (numpy, scipy, dask, matplotlib, etc.), removal of the include-v2 option, and workflow updates that are not directly related to the ndarray.shape deprecation issue. Clarify whether dependency upgrades and include-v2 removal should be part of this PR or should be separated into distinct pull requests focused on their respective objectives.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Avoid deprecated assign to ndarray.shape' is concise (40 characters), clearly describes the main objective of the PR, and does not end with a period.
Description check ✅ Passed The description clearly relates to the changeset by explaining the PR closes issues #8019 and #8025 related to deprecated ndarray.shape assignments, and references NumPy 2.5 deprecation warnings addressed in the code changes.
Linked Issues check ✅ Passed The code changes comprehensively address both linked issues: replacements of deprecated ndarray.shape assignments with np.reshape(copy=False) throughout multiple files (pil_plugin.py, marching_cubes_lewiner.py, grayreconstruct.py, rolling_ball_cy.pyx, _map_array.py), plus dependency upgrades to NumPy 2.1+ and build configuration adjustments.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

lagru and others added 4 commits February 5, 2026 17:15
Use `.reshape(..., copy=False)` instead as recommended by NumPy. I'm a
bit scared because our test suite seems to have only triggered one
instance of these warnings (in grayreconstruct.py", line 216, in
`reconstruction`)?
@stefanv stefanv force-pushed the upd-deprecated-shape-assign branch from c571516 to ba5595f Compare February 6, 2026 01:15
@lagru lagru marked this pull request as ready for review March 3, 2026 20:43
@stefanv stefanv self-requested a review March 3, 2026 20:44
@lagru lagru marked this pull request as draft March 3, 2026 20:44
@lagru
Copy link
Copy Markdown
Member Author

lagru commented Mar 3, 2026

Will review shortly.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d0aded and 87d5597.

📒 Files selected for processing (15)
  • environment.yml
  • meson.options
  • pyproject.toml
  • requirements/default.txt
  • requirements/docs.txt
  • requirements/optional.txt
  • requirements/optional_free_threaded.txt
  • src/meson.build
  • src/skimage/feature/sift.py
  • src/skimage/graph/_mcp.pyx
  • src/skimage/io/_plugins/pil_plugin.py
  • src/skimage/measure/_marching_cubes_lewiner.py
  • src/skimage/morphology/grayreconstruct.py
  • src/skimage/restoration/_rolling_ball_cy.pyx
  • src/skimage/util/_map_array.py
💤 Files with no reviewable changes (1)
  • meson.options

# Do not edit this file; modify pyproject.toml instead.
numpy>=1.24
scipy>=1.11.4
numpy>=2.1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What about SPEC0 saying that we still need to support v2.0? Are you anticipating that our next release is after that can be dropped?

Copy link
Copy Markdown
Member

@stefanv stefanv Mar 5, 2026

Choose a reason for hiding this comment

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

Yes, I think so (Q3 2026).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@stefanv I know you mentioned that you needed to update a few dependencies here, but I don't remember why. Could you maybe briefly summarize why?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I had to update NumPy, and then another dependency to match that etc. etc. It was the standard cascade. But I was pretty careful not to pull in very new packages.

@stefanv stefanv marked this pull request as ready for review March 5, 2026 08:50
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
environment.yml (1)

11-12: Consider removing duplicate tifffile entry.

tifffile>=2025.1.10 appears both in the base section (line 11) and the docs section (line 40). Since docs dependencies implicitly include base dependencies, the entry on line 40 is redundant.

Also applies to: 40-40


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1006efd3-061a-40f7-8f9d-14a375214488

📥 Commits

Reviewing files that changed from the base of the PR and between 87d5597 and 7dc6f18.

📒 Files selected for processing (2)
  • environment.yml
  • pyproject.toml

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pyproject.toml (1)

228-230: Improve warning filter comments to decouple from upstream versions.

The comments at lines 227–230 tie suppressions to specific upstream versions, creating maintenance burden. Reword them to track upstream status generically and establish clear removal conditions:

♻️ Suggested wording update
-    # Warning caused by matplotlib 3.7.0 because it uses deprecated API of pyparsing 3.3.1
+    # Upstream matplotlib emits pyparsing deprecation warnings; remove when matplotlib>=3.10.7 or fixes the deprecated calls.
     "ignore:.*(parseString|resetCache|enablePackrat|oneOf).*:DeprecationWarning:matplotlib",
-    # tifffile (v2025.12.20) uses deprecated NumPy API
+    # Upstream tifffile emits ndarray.shape deprecation warnings; remove when upstream fix is released.
     "ignore:Setting the shape on a NumPy array:DeprecationWarning:tifffile",

The matplotlib case is solvable (fix available in v3.10.7+). The tifffile case awaits upstream action on the ndarray.shape setter issue. Either way, the comments should orient maintainers toward removal conditions rather than version snapshots.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1a3938ca-080d-4152-9823-5644b8c6fc18

📥 Commits

Reviewing files that changed from the base of the PR and between 01a5f66 and c3459ed.

📒 Files selected for processing (3)
  • environment.yml
  • pyproject.toml
  • requirements/default.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • requirements/default.txt

@stefanv stefanv force-pushed the upd-deprecated-shape-assign branch from c3459ed to 01a5f66 Compare March 5, 2026 19:59
@stefanv stefanv merged commit 7737c04 into scikit-image:main Mar 5, 2026
25 checks passed
@stefanv stefanv added this to the 0.27 milestone Mar 5, 2026
matthew-brett added a commit that referenced this pull request Apr 10, 2026
* origin/main: (27 commits)
  Move `_shared` to `_skimage2` (#8102)
  Port `pad_footprint` & `mirror_footprint` to `skimage2` (#8094)
  Add rescaling API to skimage2 (#8075)
  Move `skimage2` implementation into `_skimage2` (#8093)
  Undo (double) mirroring in `ski2.morphology.dilation` (#8060)
  Grammar (#8091)
  Move `ensure_spacing` into `skimage2` (#8067)
  Ensure that `skimage2` does not eagerly import `skimage` (#8087)
  Use lazy-loader 0.5 (#8080)
  MAINT: make ellipse fitting forward compatible  (#8054)
  Avoid deprecated assign to ndarray.shape (#8020)
  Avoid circular import in `feature/corner.py` (#8077)
  Turn off coderabbit auto-labeling & label checks (#8070)
  Fix GIL being re-enabled by C++ extensions (#8059)
  Fix conventions following docstub and misc. (#8055)
  Port grayscale morphology operators to skimage2 (#8046)
  Add revised `peak_local_max` to `skimage2` (#8039)
  Allow read-only arrays as input to remap (#7535)
  Add `prescale`  parameter to "blob functions" (#7858)
  Try to make coderabbit respect exisiting type labels (#8042)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning: Setting the shape on a NumPy array has been deprecated in NumPy 2.5. ⚠ nightly test failed on main

2 participants