Skip to content

Deprecate filter argument in iradon due to clash with python keyword - #4158

Merged
lagru merged 27 commits into
scikit-image:masterfrom
rfezzani:Deprecate_filter_argument_in_iradon
Feb 18, 2020
Merged

lagru merged 27 commits into
scikit-image:masterfrom
rfezzani:Deprecate_filter_argument_in_iradon

Conversation

@rfezzani

@rfezzani rfezzani commented Sep 13, 2019 •

Copy link
Copy Markdown
Member

Description

This PR is about deprecating the reserved Python keyword filter used as argument for iradon function. It is related to the issue #4152.

filter is replaced by filter_name in the definition and documentation of iradon and the decorator deprecate_arg is defined in skimage._shared.utils and used to raise a DeprecationWarning if the old argument is explicitly used by the user and replace it by the new argument name.

Checklist

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • Consider backporting the PR with @meeseeksdev backport to v0.14.x

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

This is a decent approach for simple deprecations such as this one. I would like to see the addition of warnings being issued, as well as more information being displayed in the docstring, two things that are easy for developers to see and do without a decorator. Not to mention, a test would go a long way.

I've done alot of this stuff in
https://github.com/hmaarrfk/wabisabi

Comment thread skimage/_shared/utils.py Resolved
Comment thread skimage/transform/radon_transform.py Resolved
Comment thread skimage/_shared/utils.py Resolved
Comment thread skimage/_shared/utils.py Resolved
Comment thread skimage/_shared/utils.py Resolved
Comment thread skimage/transform/radon_transform.py Resolved
Comment thread skimage/transform/radon_transform.py Resolved
@hmaarrfk

Copy link
Copy Markdown
Member

You don't need to pass all tests from wabisabi. Generally, Ive Found that the tests help me find bugs in my own code that might be difficult to spot. You should also consider what you want you to happen when the user specifies the argument with both names

Comment thread skimage/_shared/utils.py Resolved
@rfezzani

Copy link
Copy Markdown
Member Author

I am not sure that we should consider the case where the user specifies the argument with both names: the deprecation mechanism is made to manage old users code. Using both arguments name is a user bug not an skimage bug :-)

@sciunto sciunto added this to the 0.17 milestone Sep 23, 2019
Comment thread skimage/_shared/utils.py Resolved

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

This is interesting. Although I wonder if the decorator interferes with the displayed signature for tools such as help(), sphinx or IPythons "?". If not, maybe it's not worth it to use a fancy decorator to save a few explicit and simple lines of code...

Comment thread skimage/_shared/utils.py Resolved
Comment thread skimage/_shared/utils.py Resolved
Comment thread skimage/_shared/utils.py Resolved
Comment thread skimage/_shared/utils.py Resolved
@rfezzani

Copy link
Copy Markdown
Member Author

Thank you @lagru for your review and comments. The functools.warps decorator is the generic tool to manage the docstring and function name and signature stuff. So there is no impact on that side with this decorator, but I can add a test for that ;-)

@lagru

lagru commented Oct 22, 2019

Copy link
Copy Markdown
Member

Thank you @lagru for your review and comments. The functools.warps decorator is the generic tool to manage the docstring and function name and signature stuff. So there is no impact on that side with this decorator, but I can add a test for that ;-)

Just tested locally. At least help() and IPyton's "?" aren't affected. So you're right. I don't think you need to add a test for that.

@rfezzani

Copy link
Copy Markdown
Member Author

@lagru , I already implemented the test, it doesn't hurt ;-)

@hmaarrfk

Copy link
Copy Markdown
Member

@rfezzani if you are going to get into docstring mangling, then maybe it becomes worthwhile to take the code (tests or implementation) from: https://github.com/hmaarrfk/wabisabi shameless plug again, but it was developed for these usecases. Ultimately, I decided it wasn't worth imposing the custom decorator on others. But you are soon approaching some of the other features of the wabisabi decorator.

@rfezzani

rfezzani commented Oct 23, 2019 •

Copy link
Copy Markdown
Member Author

@hmaarrfk, I am not planning to go into docstring mangling, unless you think it is a good idea...
I would prefer to keep it simple: deprecating and argument consists only in decorating the target function and replacing old argument by the new one wherever it is necessary (code and doc).

@rfezzani

rfezzani commented Dec 4, 2019

Copy link
Copy Markdown
Member Author

Hi everyone, do you think that this PR still needs more work or is it fine?
If it is merged, I would be happy to go on fixing #4152 using the deprecate_kwarg decorator ;-)

@jni

jni commented Dec 6, 2019

Copy link
Copy Markdown
Member

@rfezzani as mentioned on my comment in #4161, I don't have time to review right now but I hope to get more time back in the coming weeks. Hold, please! =) (Or maybe someone else will review before me, but just wanted to make sure you're not just left feeling hanging. =)

@rfezzani

rfezzani commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

No problem @jni, I am just searching some more issues to work on ;-)

@jni

jni commented Dec 6, 2019

Copy link
Copy Markdown
Member

I am just searching some more issues to work on ;-)

Oh, that we can provide in spades! 😂 Did you see my post on the mailing list about n-dimensional edge filters, for example? =)

@rfezzani

rfezzani commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

Yes, I saw it, very cool! But I also saw on your message that you will submit a PR soon on that 😄

@rfezzani rfezzani added action: mrg+1 🔧 type: Maintenance Refactoring and maintenance of internals labels Jan 25, 2020
@sciunto sciunto added the 🔽 Deprecation Involves deprecation label Feb 3, 2020
@hmaarrfk

Copy link
Copy Markdown
Member

I think the only thing missing from this is a ..versionchanged in the docstring.

@rfezzani

Copy link
Copy Markdown
Member Author

I added it @hmaarrfk ;-)

@hmaarrfk hmaarrfk changed the title Deprecate filter argument in iradon Deprecate filter argument in iradon due to clash with python keyword Feb 14, 2020
@hmaarrfk

Copy link
Copy Markdown
Member

whoa, so many failures.

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

@rfezzani Looks good! Sorry for holding this up a little further but could you add a note to the Version 0.19 section in TODO.txt about this deprecation? I tried doing this myself but got in trouble with git somewhere along the way. 😅

Otherwise this is ready to merge.

@rfezzani

Copy link
Copy Markdown
Member Author

Thank you very much @lagru, fixing #4003, #4154 and #4152 will be much more handy now 😉

@lagru
lagru merged commit 0981cd7 into scikit-image:master Feb 18, 2020
@lagru

lagru commented Feb 18, 2020

Copy link
Copy Markdown
Member

@rfezzani Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔽 Deprecation Involves deprecation 🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants