Repository navigation
Port feature.canny to skimage2 - #8047
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
src/skimage2/feature/_canny.py (1)
8-13: Align import conventions (SciPy alias + relative shared utils).Guidelines prefer
import scipy as spand relative imports undersrc/**. Here we usescipy.ndimage as ndiand absoluteskimage.*imports. If skimage2 is meant to be self-contained, consider routing shared utilities via a skimage2._shared module and using relative imports; otherwise confirm this dependency is intentional.♻️ Example adjustment for SciPy alias
-import scipy.ndimage as ndi +import scipy as spAs per coding guidelines: Use import conventions:
import numpy as np,import matplotlib.pyplot as plt,import scipy as sp,import skimage as ski; andsrc/**/*.py: Use relative module imports (e.g.,from .._shared import xyzrather thanfrom skimage._shared import xyz).tests/skimage2/feature/test_canny.py (1)
169-177: Consider adding explicit test for the new defaultmode='nearest'behavior.The PR changes the default
modefrom"constant"to"nearest". Whiletest_full_mask_matches_no_masktests multiple modes explicitly, there's no test that verifies the default mode behavior has changed. Adding a test that confirmscanny(image)usesmode='nearest'semantics (or comparing output against an explicitmode='nearest'call) would help document and protect this intentional API change.
86da26c to
a6f09e1
Compare
lagru
left a comment
There was a problem hiding this comment.
We are updating the type descriptions to conform with docstub as we port to skimage2. The discussion regarding details is still ongoing but here and there we can already tweak things.
lagru
left a comment
There was a problem hiding this comment.
Looks really good from the get go. Nothing major outside the need to duplicate the test suite. Going by how the other PRs went, there'll be a bit of cleanup of the ported function in general after that. Shouldn't be too far off from getting this in.
|
@michaelbratsch Thanks so much for helping here; as you can see for the PRs, not many are brave enough to wade into these waters :) |
There was a problem hiding this comment.
Thank you so much for tackling this, @michaelbratsch!
Most comments / suggestions are not related to your contribution directly, but come from the 'old' canny and we are just seeing now some areas for improvement... We'll work through these with you! 🙏
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
meson.build (1)
50-50:⚠️ Potential issue | 🔴 CriticalUpdate line 50 to use the new path for the linker script.
The linker script file
link-version-pyinit.maponly exists atsrc/skimage2/_build_utils/, not at the old location. Line 50 still referencessrc/skimage/_build_utils/link-version-pyinit.mapand needs to be updated tosrc/skimage2/_build_utils/link-version-pyinit.mapto be consistent with the path updates on lines 7, 61, and 62.
🧹 Nitpick comments (2)
src/meson.build (2)
82-82: Redundantccredeclaration.
ccis already declared in the top-levelmeson.build(line 17) and should be visible in this subdir. This redeclaration is unnecessary.
118-140:cython_cpp_argsis defined on line 123 then immediately overwritten on line 140 with unrelated content.Line 123 defines
cython_cpp_argsas Cython CLI arguments (['@INPUT@', '@OUTPUT@', '--cplus']), but line 130 already inlines these args directly in the generator call, making line 123 dead code. Then line 140 reassignscython_cpp_argsto compiler warning flags (cython_c_args).This works but the naming overlap is confusing. Consider removing the dead assignment on line 123, or renaming the compiler-args variable (e.g.,
cython_cpp_c_args) to distinguish it from the CLI args.
1f7c5d5 to
19aa4a1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/skimage2/feature/_canny.py (1)
11-13: Cross-package imports fromskimageinternals intoskimage2.These absolute imports from
skimage._sharedandskimage.utilare necessary since relative imports can't cross package boundaries. However, this couplesskimage2toskimageinternal modules (_shared.filters,_shared.utils,util.dtype). As the migration toskimage2progresses, consider whether these shared utilities should be lifted into a common internal package or duplicated intoskimage2to allowskimageto eventually become a thin wrapper without circular dependencies.#!/bin/bash # Check if skimage2 has its own _shared or util modules fd -t f -p 'skimage2/_shared' -p 'skimage2/util' echo "---" # Check how other skimage2 modules handle imports from skimage rg -n "from skimage\." --type=py -g 'src/skimage2/**'
c5e9d7f to
66c401a
Compare
66c401a to
de3b262
Compare
Ahh right, that was a misunderstanding. I now added a unit test to check for the new default of the |
lagru
left a comment
There was a problem hiding this comment.
Perfect. Ready to merge now and thank you for the work.
Conflicts: src/_skimage2/feature/_canny.py src/_skimage2/feature/_canny_cy.pyx
|
@michaelbratsch, note that #8093 recently moved all skimage2 implementations into |
Thank you for resolving the latest merge conflicts from master. From my side the pull request is complete. I guess now one more approval is missing for the merge. I saw that one unit test for macOS python 3.13 is failing which I can't reproduce on my Mac M1. Is this test know to be unstable? |
| # Smooth out the masked image. | ||
| smoothed_image = gaussian(masked_image, **gaussian_kwargs) | ||
|
|
||
| # Lower the result by the bleed-over fraction, so you can |
Yes, very much annoyingly so. See #7964 for the details. We temporarily marked it as an expected failure scikit-image/tests/skimage/restoration/test_unwrap.py Lines 135 to 140 in 16df38b That has expired now. 💁 |
Co-authored-by: Stefan van der Walt <[email protected]>
Having an expected failure with a timeout is a funny concept but I get the point in wanting to come back to it later. Maybe the flaky behaviour is fixed by https://github.com/scikit-image/scikit-image/pull/8099/changes |
Conflicts: src/_skimage2/feature/_canny_cy.pyx src/meson.build src/skimage/feature/_canny.py src/skimage/meson.build
|
Reviews (1): Last reviewed commit: "Merge branch 'main' into 'move_canny_to_..." | Re-trigger Greptile |
|
Reviews (2): Last reviewed commit: "Note keyword-only change in message" | Re-trigger Greptile |
lagru
left a comment
There was a problem hiding this comment.
I took the liberty to resolve the merge conflicts caused by _shared being moved to _skimage2.
We still need to port the existing tests in test_canny to skimage2. But I'll do a a quick follow-up PR for that.
I'll merge if the CI stays happy, because I am. Thank you @michaelbratsch!
* 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)
Followup to #8047. This ports the full test suite for features.canny to skimage2.
Description
Adds the function
cannyto the skimage2 namespace. Compared to the old version in skimage it uses for the optional parametermodethe defaultnearestinstead ofconstant.See https://github.com/scikit-image/scikit-image/wiki/API-changes-for-skimage2#skimagefeature
Release note
For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.