Skip to content

Add skimage2 porting decorator - #8114

Merged
lagru merged 48 commits into
scikit-image:mainfrom
matthew-brett:ski2-docstrings
Apr 24, 2026
Merged

lagru merged 48 commits into
scikit-image:mainfrom
matthew-brett:ski2-docstrings

Conversation

@matthew-brett

@matthew-brett matthew-brett commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

This implements a decorator that a) adds a Skimage2 warning and b) stored a ReST doc fragment for later insertion into the migration doc.

This allows us to a) avoid having to raise standard warnings inside the deprecated functions (the decorator can do that) and b) avoid having to write two versions of the explanation, one for the user warning, and another to go into the migration doc.

It also allows us to insert a standard link, in the warning, to the relevant part of the migration guide.

Then, in the doc build, we a) import skimage as ski with EAGER_IMPORT set, and b) collect all the stored Skimage2 doc fragments, and insert them into the migration doc with Jinja2 templating.

In general, my hope is that this will streamline the process of writing and maintaining warnings and the migration documentation for Skimage2 porting, by keeping the warning and the doc as close as possible (and mostly based on the same source), and keeping the warning / doc very close to the function being ported (as a preceding docstring as argument to the Skimage2 decorator).

We can also, in due course, add the porting / migration docstring parts into the docstrings of the decorated functions, but I haven't done that here.

When agreed, I will write up a section maybe in the Skimage2 SKIP, on using this system to write Skimage2 migration docstrings.

@greptile-apps

greptile-apps Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "Start of migration docstring machinery" | Re-trigger Greptile

Comment thread src/_skimage2/util/__init__.pyi Resolved
Comment thread src/_skimage2/util/migration.py Resolved
Comment thread src/_skimage2/util/migration.py Resolved
Comment thread src/_skimage2/util/migration.py Resolved
Comment thread src/_skimage2/util/migration.py Resolved
@greptile-apps

greptile-apps Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.
Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Reviews (2): Last reviewed commit: "Start of migration docstring machinery" | Re-trigger Greptile

Comment thread src/_skimage2/util/migration.py Resolved
Comment thread src/_skimage2/util/migration.py Resolved
Comment thread tests/skimage2/util/test_migration.py Resolved
@lagru
lagru self-requested a review April 6, 2026 15:50
@lagru lagru added 🥾 Path to skimage2 A step towards the new "API 2.0" 🔧 type: Maintenance Refactoring and maintenance of internals labels Apr 6, 2026
@github-project-automation github-project-automation Bot moved this to Pitched in Work pitches Apr 6, 2026
@lagru lagru moved this from Pitched to Review in Work pitches Apr 6, 2026
@greptile-apps

greptile-apps Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Reviews (5): Last reviewed commit: "Rework the migration document parsing" | Re-trigger Greptile

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This review covers three documentation and formatting bugs in the new migration annotation blocks. These are separate from issues flagged in earlier review threads.

Issue 1 — src/skimage/feature/peak.py (lines 64–82): The migration doc example block has six distinct bugs: an undefined variable (image vs img), wrong module path for peak_local_max (morphology instead of feature), a duplicate positional argument, two assert lines missing their >>> prefix, a missing closing ), and an unclosed ```python code fence. The example will not run correctly and the rendered Markdown will be malformed.

Issue 2 — src/skimage/morphology/gray.py line 45 (_PENDING_SKIMAGE2_TEMPLATE_NO_MIRROR): A stray closing ``` fence with no matching opening fence. Will render as broken Markdown.

Issue 3 — src/skimage/morphology/gray.py line 102 (_PENDING_SKIMAGE2_TEMPLATE_MIRROR): Same stray closing ``` fence problem.

See inline comments for precise locations and suggested fixes.

Comment thread src/skimage/feature/peak.py Resolved
Comment thread src/skimage/morphology/gray.py Resolved
Comment thread src/skimage/morphology/gray.py Resolved
@greptile-apps

greptile-apps Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Reviews (6): Last reviewed commit: "Work out gray morphology docstrings" | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Reviews (7): Last reviewed commit: "Footprint deprecation messages." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Reviews (8): Last reviewed commit: "Greptile review" | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Vulnerabilities

No security concerns identified.

Reviews (9): Last reviewed commit: "Parse out Python blocks" | Re-trigger Greptile

Comment thread src/skimage/morphology/gray.py Resolved
Comment thread src/skimage/feature/peak.py Outdated
Comment on lines +74 to +77
>>> res2 = ski2.feature.peak_local_max(image,
... min_distance=10,
... exclude_border=10,
... p_norm=np.inf)

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.

Could we stick to our established formatting as imposed by our pre-commit hooks?

In cases like this, it otherwise leads to a slightly ridiculous indent. 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I ran the commit hooks - but I also can't see the problem with the indent in my editor. Could you fix to your preferred indent?

@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (27): Last reviewed commit: "Remove unused regexes" | Re-trigger Greptile

lagru added 2 commits April 23, 2026 14:03
Its name isn't very expressive, it contains only two trivial lines and
it makes tests significantly harder to read.
@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (28): Last reviewed commit: "Prefer top-level .gitignore" | Re-trigger Greptile

@matthew-brett

matthew-brett commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor Author

For the .gitignore thing - it's not something I care greatly about, but I personally try and put stuff in the .gitignore that is relevant to the tree I'm in - which isn't the directory where the file is, usually. So I'd tend to put general things in the top level file, but doc-related stuff in the doc tree. I find it makes it easier to reason about what's in the .gitignore because otherwise the top-level file fills up with all sorts of stuff that is specific to particular parts of the code - such as the docs.

@matthew-brett

Copy link
Copy Markdown
Contributor Author

Sorry - I can't any longer track down the comments that are arriving in my email in-box - the links don't work, and I can't find the comments in the Github interface. So replying here:

Yes, I prefer not to ask the user to type an identifying end-marker, even though it can be inferred. I might feel differently if one could embed one marker inside another, but as it is, I as the docstring author would be thinking "why did you make me type this?".

Go ahead with adding the comment to the regex.

@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (29): Last reviewed commit: "Simplify `_parse_migration_doc` and add ..." | Re-trigger Greptile

Comment thread src/skimage/_migration.py Resolved
* origin/main:
  Drop 3.13t builds from cibuildwheel configuration (scikit-image#8127)
  Restore wording of AI policy (scikit-image#8123)
  Port feature.canny to skimage2 (scikit-image#8047)
  Revert "Add AI contribution policy (scikit-image#7982)" (scikit-image#8124)
  Add AI contribution policy (scikit-image#7982)
@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (30): Last reviewed commit: "Move Canny migration advice into decorat..." | Re-trigger Greptile

lagru added 5 commits April 23, 2026 19:18
It was only used once and the name wasn't terribly expressive. Also
simplify logic somewhat.
I think this version is somewhat easier to grok and document. It's
also easier to test independently, see the new test.
@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (31): Last reviewed commit: "Simplify `_context_rep` to `_select_bloc..." | Re-trigger Greptile

@lagru lagru left a comment

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.

@matthew-brett, I pushed a few more refactors, a new test and added the possibility to locally override the warning class. The latter really helps local testing in the command line.

Feel totally free to revert, improve and/or criticize! 😊

Nearly done. Hope to approve this today. 🙏

@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (32): Last reviewed commit: "Format doctest in black's style" | Re-trigger Greptile

@lagru lagru left a comment

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.

Ready to go!

@lagru lagru changed the title Skimage2 porting docstring machinery Add skimage2 porting decorator Apr 24, 2026
@lagru
lagru merged commit 099a03d into scikit-image:main Apr 24, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from Doing to Done in Work pitches Apr 24, 2026
@stefanv stefanv added this to the 0.27 milestone Apr 24, 2026
@matthew-brett
matthew-brett deleted the ski2-docstrings branch April 24, 2026 08:14
matthew-brett added a commit that referenced this pull request Apr 27, 2026
* origin/main:
  Port tests for `features.canny` to skimage2 (#8126)
  Replace NumPy global RNG use in tests with local seeded RNGs (#8084)
  Disable tests using matplotlib on pyodide (#8082)
  Test with pythonoptimize (#8108)
  Add skimage2 porting decorator (#8114)
  Drop 3.13t builds from cibuildwheel configuration (#8127)
  Restore wording of AI policy (#8123)
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.

3 participants