Repository navigation
Add skimage2 porting decorator - #8114
Conversation
|
Reviews (1): Last reviewed commit: "Start of migration docstring machinery" | Re-trigger Greptile |
1dcfc7d to
78827a6
Compare
|
Greploops — Automatically fix all review issues by running Reviews (2): Last reviewed commit: "Start of migration docstring machinery" | Re-trigger Greptile |
78827a6 to
54913c7
Compare
54913c7 to
9f08bc2
Compare
[skip ci]
c30dd39 to
d9d2dc3
Compare
|
Reviews (5): Last reviewed commit: "Rework the migration document parsing" | Re-trigger Greptile |
There was a problem hiding this comment.
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.
|
Reviews (6): Last reviewed commit: "Work out gray morphology docstrings" | Re-trigger Greptile |
|
Reviews (7): Last reviewed commit: "Footprint deprecation messages." | Re-trigger Greptile |
|
Reviews (8): Last reviewed commit: "Greptile review" | Re-trigger Greptile |
[skip-ci]
|
| >>> res2 = ski2.feature.peak_local_max(image, | ||
| ... min_distance=10, | ||
| ... exclude_border=10, | ||
| ... p_norm=np.inf) |
There was a problem hiding this comment.
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. 😅
There was a problem hiding this comment.
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?
|
Reviews (27): Last reviewed commit: "Remove unused regexes" | Re-trigger Greptile |
Its name isn't very expressive, it contains only two trivial lines and it makes tests significantly harder to read.
|
Reviews (28): Last reviewed commit: "Prefer top-level .gitignore" | Re-trigger Greptile |
|
For the |
|
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. |
|
Reviews (29): Last reviewed commit: "Simplify `_parse_migration_doc` and add ..." | Re-trigger Greptile |
* 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)
|
Reviews (30): Last reviewed commit: "Move Canny migration advice into decorat..." | Re-trigger Greptile |
Should improve readability.
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.
|
Reviews (31): Last reviewed commit: "Simplify `_context_rep` to `_select_bloc..." | Re-trigger Greptile |
lagru
left a comment
There was a problem hiding this comment.
@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. 🙏
|
Reviews (32): Last reviewed commit: "Format doctest in black's style" | Re-trigger Greptile |
* 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)
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 skiwithEAGER_IMPORTset, 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.