Skip to content

Deprecate output and positional args in filters.gaussian - #7225

Merged
soupault merged 13 commits into
scikit-image:mainfrom
lagru:deprecate-gaussian-output
Mar 15, 2024
Merged

soupault merged 13 commits into
scikit-image:mainfrom
lagru:deprecate-gaussian-output

Conversation

@lagru

@lagru lagru commented Oct 27, 2023 •

Copy link
Copy Markdown
Member

Description

Addresses an item in our skimage2 transition list. We can't simply use deprecate_kwarg or remove_arg, as output can also be passed as a positional argument. Instead, deprecate passing more than 1 positional argument and at the same time, refactor output to out.

I'm not really sure whether remove_arg is a user friendly way to deprecate a positional parameter. Applying the function prevents positional arguments after the deprecated one as well, even though this is not deprecated. The warning will users also not tell them about it. I find it clearer to just deprecate these positional arguments in favor of keyword-only ones. I also think it's the better practice.

Checklist

Release note

Summarize the introduced changes in the code block below in one or a few sentences. The
summary will be included in the next release notes automatically:

Deprecate parameter `output` in `skimage.filters.gaussian`; use `out` instead.

Addresses an item in our skimage2 transition list [1]. We can't simply
use deprecate_kwarg or remove_arg, as `output` can also be passed as a
positional argument. Instead, deprecate passing more than 1 positional
argument and at the same time, refactor `output` to `out`.

I'm not really sure whether remove_arg is a user friendly way to
deprecate a positional parameter. Applying the function prevents
positional arguments after the deprecated one as well, even though this
is not deprecated. The warning will users also not tell them about it.
I find it clearer to just deprecate these positional arguments in favor
of keyword-only ones. I also think it's the better practice.

[1] https://github.com/scikit-image/scikit-image/wiki/API-changes-for-skimage2
@lagru lagru added 🔽 Deprecation Involves deprecation 📜 type: API Involves API change(s) labels Oct 27, 2023

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

Nice work, @lagru! Thanks for tackling one item in the list and doing the heavy lifting...

Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/filters/tests/test_gaussian.py Resolved
@lagru
lagru marked this pull request as draft November 23, 2023 13:02
@lagru

lagru commented Nov 23, 2023

Copy link
Copy Markdown
Member Author

Thanks for the review @mkcor. I am currently working on merging and updating our remove_arg and deprecate_kwarg decorators. IMO we can combine them into a simpler deprecate_parameter that allows replacing positional parameters as well. That's currently more awkward then necessary. And we will need to do so for skimage2 quite a bit.

After that I'll address your feedback and update this PR accordingly.

@lagru
lagru marked this pull request as ready for review January 18, 2024 23:09
@lagru

lagru commented Jan 18, 2024

Copy link
Copy Markdown
Member Author

@mkcor, sorry for the "Marked as resolved / unresolved" spam, I got confused. 🙈

This should be ready to review / merge.

@lagru

lagru commented Jan 18, 2024

Copy link
Copy Markdown
Member Author

@scikit-image/core, this would be good to prioritize as a step towards skimage2. 🙏

@lagru lagru added the 🥾 Path to skimage2 A step towards the new "API 2.0" label Jan 18, 2024
@lagru
lagru requested a review from mkcor February 26, 2024 12:41
lagru and others added 2 commits February 26, 2024 13:48

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

Great work, @lagru! Only left minor suggestions.

Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
Comment thread skimage/_shared/filters.py Resolved
lagru and others added 4 commits February 29, 2024 12:48
Co-authored-by: Marianne Corvellec <[email protected]>
as suggested by Marianne. I felt like "got" conveyed the same meaning
as "provided" but is a bit less advanced vocabulary.
which was recently merged.
@soupault

Copy link
Copy Markdown
Member

Thank you, Lars!

deprecate passing more than 1 positional argument

If it is still planned for the current branch, I think it would be acceptable to have both deprecations running at the same time. The implementation could then count the number of arguments passed positionally (e.g. as in https://stackoverflow.com/questions/67639234/count-how-many-arguments-passed-as-positional).

No comments to the PR otherwise, and I am happy to proceed with the current version.

@lagru

lagru commented Mar 14, 2024

Copy link
Copy Markdown
Member Author

Good call @soupault. I forgot to update the original intention in the PR description. I originally wanted to turn sigma into a keyword-only parameter as well but then decided to focus on the actual goal of the PR (I think).

I'd be happy if we turned that parameter into a keyword-only one but think it would be reasonable to do it in another PR perhaps?

@soupault
soupault merged commit 9107d52 into scikit-image:main Mar 15, 2024
@stefanv stefanv added this to the 0.23 milestone Mar 15, 2024
@soupault

Copy link
Copy Markdown
Member

Sure. Thanks for working on this!

@lagru
lagru deleted the deprecate-gaussian-output branch March 16, 2024 18:46
@lagru lagru mentioned this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔽 Deprecation Involves deprecation 🥾 Path to skimage2 A step towards the new "API 2.0" 📜 type: API Involves API change(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants