Skip to content
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

Merged

Conversation

Larkinnjm1
Copy link
Contributor

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

  • Docstrings for all functions
  • Benchmark in ./benchmarks, if your changes aren't covered by an
    existing benchmark
  • Unit tests
  • Clean style in the spirit of PEP8

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.

".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
@pep8speaks
Copy link

pep8speaks commented Aug 12, 2021

Hello @Larkinnjm1! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 193:80: E501 line too long (85 > 79 characters)

Comment last updated at 2021-08-19 15:12:07 UTC

skimage/restoration/_denoise.py Outdated Show resolved Hide resolved
skimage/restoration/_denoise.py Outdated Show resolved Hide resolved
skimage/restoration/_denoise.py Outdated Show resolved Hide resolved
"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.'))
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Contributor

@grlee77 grlee77 Aug 18, 2021

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool thanks for the input @grlee77 and @mkcor I will amend this item then.

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.'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

Copy link
Contributor Author

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/_masked_phase_cross_correlation.py Outdated Show resolved Hide resolved
Larkinnjm1 and others added 4 commits August 18, 2021 15:55
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>
…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.
Copy link
Member

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

@hmaarrfk
Copy link
Member

Sorry for then noise. grlee already asked for a specific style. Lets follow it. This looks good to me.

Copy link
Contributor

@grlee77 grlee77 left a 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.

The removal was done in a recently merged PR

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>
@grlee77
Copy link
Contributor

grlee77 commented Aug 19, 2021

Sorry for then noise. grlee already asked for a specific style. Lets follow it. This looks good to me.

No worries, thanks for reviewing! For reference, we discussed this style choice previously during the SciPy sprint: #5478 (review)

@grlee77
Copy link
Contributor

grlee77 commented Aug 19, 2021

Thanks @Larkinnjm1, just waiting for CI to finish before merging

@grlee77 grlee77 merged commit 118d813 into scikit-image:main Aug 19, 2021
@grlee77
Copy link
Contributor

grlee77 commented Aug 19, 2021

The one CI failure that was observed is due to an unrelated PR that was merged and is resolved by #5522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants