-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.format() coverted to f-strings in registration & restoration subpackage #5510
.format() coverted to f-strings in registration & restoration subpackage #5510
Conversation
".format()" of strings objects modified to f-strings within registration and restoration packages of library per issue scikit-image#5474. Committer: Niall Larkin <nialllarkin@nialls-mbp.home> On branch registration_restoration_fstrings Changes to be committed: modified: skimage/registration/_masked_phase_cross_correlation.py modified: skimage/registration/tests/test_masked_phase_cross_correlation.py modified: skimage/restoration/_denoise.py
Hello @Larkinnjm1! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-08-19 15:12:07 UTC |
skimage/restoration/_denoise.py
Outdated
"likely to be suboptimal.").format(wavelet.name)) | ||
warn((f'Wavelet thresholding was designed for use with orthogonal ' | ||
f'wavelets. For nonorthogonal wavelets such as {wavelet.name}, results are ' | ||
f'likely to be suboptimal.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there an (unnecessary) extra pair of brackets here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback this is what was in the original code base they held these strings in a tuple so I used the same object as a result. Looking at the warn
object from _warnings.py
in the _ shared
directory there is no impact in using a string directly. However with the fstrings being in a tuple you don't have to include a back slash at the end of each new line of text to avoid getting an IndentationError. Hence putting it in a tuple is potentially less error prone. Is this the potential reason why the code was written like this originally does any of the OGs know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually already just a string and not a tuple, since there is no comma within the parentheses. I don't think there is a good reason to keep it this way and would just remove the extra parentheses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skimage/restoration/_denoise.py
Outdated
warn(("Thresholding method {} selected. The user-specified threshold " | ||
"will be ignored.").format(method)) | ||
warn((f'Thresholding method {method} selected. The user-specified threshold ' | ||
f'will be ignored.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the same response above to the braketing (tuple) object issue.
skimage/registration/tests/test_masked_phase_cross_correlation.py
Outdated
Show resolved
Hide resolved
1. Reformatting of strings in the following functions following pull request review from mkcor: - def cross_correlate_masked - def denoise_bilateral 2. Reinstatement of function "def test_deprecated_masked_register_translation" reformatted in error. Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
…nto registration_restoration_fstrings
…m/Larkinnjm1/scikit-image into registration_restoration_fstrings Merged with remote changes made per d9bc06b
On branch registration_restoration_fstrings Changes to be committed: modified: skimage/restoration/_denoise.py _denoise.py updated as a result of review performed by PEP8speaks, mkcor and grlee77 to pull request scikit-image#5510 modifications made: - reduction of line lenght per PEP8 review E501 errors - removal of brackets from f-strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For concatenating strings, you only need an f on the portions that have fields to format.
Sorry for then noise. grlee already asked for a specific style. Lets follow it. This looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See suggestions on test case removal. This was the cause of the current CI failure.
skimage/registration/tests/test_masked_phase_cross_correlation.py
Outdated
Show resolved
Hide resolved
skimage/registration/tests/test_masked_phase_cross_correlation.py
Outdated
Show resolved
Hide resolved
Updates made to 'test_masked_phase_cross_correlation.py' due to deprecated test method "test_deprecated_masked_register_translation" & "skimge.feature.masked_register_translation" included in error noted during PR review grlee77 Co-authored-by: Gregory R. Lee <grlee77@gmail.com>
No worries, thanks for reviewing! For reference, we discussed this style choice previously during the SciPy sprint: #5478 (review) |
Thanks @Larkinnjm1, just waiting for CI to finish before merging |
The one CI failure that was observed is due to an unrelated PR that was merged and is resolved by #5522 |
Description
".format()" call on strings objects modified to f-strings within registration and restoration packages of library to partially address issue #5474.
files modified:
modified: skimage/registration/_masked_phase_cross_correlation.py
modified: skimage/registration/tests/test_masked_phase_cross_correlation.py
modified: skimage/restoration/_denoise.py
Checklist
./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.