Skip to content

Ensure that skimage2 does not eagerly import skimage#8087

Merged
stefanv merged 7 commits intoscikit-image:mainfrom
lagru:sk2-inline-imports
Mar 12, 2026
Merged

Ensure that skimage2 does not eagerly import skimage#8087
stefanv merged 7 commits intoscikit-image:mainfrom
lagru:sk2-inline-imports

Conversation

@lagru
Copy link
Copy Markdown
Member

@lagru lagru commented Mar 12, 2026

Description

We recently discussed establishing a clear import hierarchy between skimage and skimage2 to avoid circular imports. The verdict was:

  • skimage can import skimage2 normally / at the top of modules
  • skimage2 should not import skimage. If it must, it should defer imports / use lazy imports

This PR updates the current code in skimage2 accordingly and enforces the hiearchy with a test.

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 🔧 type: Maintenance Refactoring and maintenance of internals 🥾 Path to skimage2 A step towards the new "API 2.0" labels Mar 12, 2026
Comment on lines +8 to +9
def _default_footprint(func):
"""Decorator to add a default footprint to morphology functions.
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.

I've moved this function to skimage2 already, because there's no trivial way to use a decorator "lazily".

@greptile-apps

This comment was marked as off-topic.

@lagru lagru moved this to Doing in Work pitches Mar 12, 2026
@lagru lagru self-assigned this Mar 12, 2026
@lagru lagru moved this from Doing to Needs review in Work pitches Mar 12, 2026
@lagru lagru moved this from Needs review to Doing in Work pitches Mar 12, 2026
@lagru lagru moved this from Doing to Needs review in Work pitches Mar 12, 2026
@stefanv stefanv merged commit 452d6b7 into scikit-image:main Mar 12, 2026
24 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Done in Work pitches Mar 12, 2026
@stefanv stefanv added this to the 0.27 milestone Mar 12, 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

🥾 Path to skimage2 A step towards the new "API 2.0" 🔧 type: Maintenance Refactoring and maintenance of internals

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants