Skip to content

Port gaussian to skimage2.filters - #8069

Merged
lagru merged 25 commits into
scikit-image:mainfrom
lagru:sk2-filters-gaussian
May 21, 2026
Merged

lagru merged 25 commits into
scikit-image:mainfrom
lagru:sk2-filters-gaussian

Conversation

@lagru

@lagru lagru commented Feb 26, 2026 •

Copy link
Copy Markdown
Member

Description

Previously, gaussian lived in skimage/_shared/ to avoid import circles. Now that lazy loading is established, I don't think that's a problem any more. So I've put it back in skimage2/filters/. If it becomes one, it's easy enough to move the function back to _shared.

In our discussion around preserve_range, we agreed to drop this keyword. We aim to use prescale where the algorithm needs to know about the value range, elsewhere we just explain users how to recover legacy behavior.

  • So we need to expose _rescale_value_range(..., mode="legacy") in skimage2 to enable users to recover the legacy behavior. I propose to do that in another PR and have marked this one as Draft for now. See Add rescaling API to skimage2 #8075

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 this to skimage2 Feb 26, 2026
@lagru lagru added 🔧 type: Maintenance Refactoring and maintenance of internals 🥾 Path to skimage2 A step towards the new "API 2.0" labels Feb 26, 2026
@github-project-automation github-project-automation Bot moved this to To Do in skimage2 Feb 26, 2026
@lagru lagru moved this to Stalled in Work pitches Mar 12, 2026
@lagru lagru self-assigned this Mar 12, 2026
@lagru lagru moved this from Stalled to Doing in Work pitches Mar 19, 2026
@lagru
lagru marked this pull request as ready for review March 23, 2026 13:25
@greptile-apps

greptile-apps Bot commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "Apply commit hooks" | Re-trigger Greptile

Comment thread src/_skimage2/filters/_gaussian.py Resolved
Comment thread src/_skimage2/filters/_gaussian.py Resolved
Comment thread src/_skimage2/filters/_gaussian.py Resolved
Comment thread src/_skimage2/filters/__init__.py Resolved
Comment thread src/_skimage2/filters/_gaussian.py Resolved
Comment on lines +10 to +13
# skimage2.filters.gaussian ------------------------------------------------------------


def test_gaussian_negative_sigma():

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.

This is why I like using classes to group test together.

Without doing that and if I want to be able to use something like pytest -k 'gaussian' effectively, I need to insert the common prefix in every test function name. And I need a comment to separate test groups at a quick glance.

Given all that I don't see what's so bad about having a test class. "We don't do classes anymore" doesn't really seem like a constructive argument that addresses these requirements. 😉

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 use file-based grouping and it works fine? 🤷 ie if you make one file per test class, it becomes exactly equivalent. pytest -k GaussianClass becomes pytest src/skimage2/filters/_tests/test_gaussian.py. I can see that it's more of a pain to type once, but on the other hand, you get autocomplete, so 🤷

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.

Having one file per function (and class?) would be a new paradigm for our test suite. Do you propose we adopt that?

@lagru lagru moved this from Doing to Review in Work pitches Mar 23, 2026
@greptile-apps

greptile-apps Bot commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Address oversights" | Re-trigger Greptile

@lagru lagru moved this from Review to Doing in Work pitches Mar 23, 2026
which is now raised internally by `gaussian`.
Comment on lines 105 to 109
mask = gaussian(
mask,
sigma=0.25 * min_length * blob_size_fraction,
preserve_range=False,
mode=boundary_mode,
mask, sigma=0.25 * min_length * blob_size_fraction, mode=boundary_mode
)
threshold = np.quantile(mask, 1 - volume_fraction)
blobs = mask >= threshold

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.

We can just use gaussian from skimage2 here without having to worry about preserve range because the thresholding is insensitive to the value range of the smoothed mask.

@greptile-apps

greptile-apps Bot commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (3): Last reviewed commit: "Fix tests that are sensitive to PendingS..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Reviews (4): Last reviewed commit: "Fix warning sensitive test_list_sigma" | Re-trigger Greptile

@blink1073 blink1073 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.

Comments about namespace usage in tests

lagru added 2 commits May 13, 2026 14:50
Conflicts:
doc/source/user_guide/skimage2_migration.rst.tpl
src/_skimage2/__init__.pyi
src/_skimage2/meson.build
src/skimage/metrics/_structural_similarity.py
@greptile-apps

This comment was marked as low quality.

@blink1073

Copy link
Copy Markdown
Contributor

This failure looks legitimate: ImportError: cannot import name 'integral_image' from partially initialized module 'skimage.transform' (most likely due to a circular import) (/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/skimage/transform/__init__.py).

@greptile-apps

This comment was marked as low quality.

@greptile-apps

This comment was marked as low quality.

@greptile-apps

This comment was marked as low quality.

Comment thread src/_skimage2/data/_synthetic.py Resolved
@lagru lagru added the 🧪 run-all-tests Run all of the tests, instead of only those in subpackages that have been modified by the PR label May 16, 2026
@greptile-apps

This comment was marked as low quality.

@greptile-apps

greptile-apps Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (14): Last reviewed commit: "Fix import circle at `from ..transform i..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (15): Last reviewed commit: "Inline even more to avoid circular impor..." | Re-trigger Greptile

@lagru
lagru requested a review from blink1073 May 16, 2026 11:52

@blink1073 blink1073 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.

LGTM

@lagru
lagru merged commit 88206aa into scikit-image:main May 21, 2026
27 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in Work pitches May 21, 2026
@github-project-automation github-project-automation Bot moved this from To Do to Done in skimage2 May 21, 2026
@stefanv stefanv added this to the 0.27 milestone May 21, 2026
@lagru
lagru deleted the sk2-filters-gaussian branch May 21, 2026 15:49
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" 🧪 run-all-tests Run all of the tests, instead of only those in subpackages that have been modified by the PR 🔧 type: Maintenance Refactoring and maintenance of internals

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

ski2.feature.canny is still using legacy scaling

4 participants