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
Dedupe spectral plotting tests. #16444
Conversation
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 a very welcome clarification and reduction in lines. I noted one point of style (indentation) I would like to see changed, but I won't insist on it.
lib/matplotlib/tests/test_axes.py
Outdated
@image_comparison([ | ||
"specgram_freqs.png", "specgram_freqs_linear.png", | ||
"specgram_noise.png", "specgram_noise_linear.png", | ||
], remove_text=True, tol=0.07, style="default") |
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.
Style nit-pick, here and below: I think this pattern of out-denting is counterproductive and impairs readability. I hope it doesn't take hold as typical practice.
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.
I personally dislike out-denting when the delimiter ends up being the sole character(s) on its own line, which is sadly the style used by the sadly (yes, twice) popular black formatter -- it would give you
@image_comparison(
[
"specgram_freqs.png",
"specgram_freqs_linear.png",
"specgram_noise.png",
"specgram_noise_linear.png",
],
remove_text=True,
tol=0.07,
style="default",
)
def test_specgram():
"""Test axes.specgram in default (psd) mode."""
(yuck! completely ignoring semantics that are not being captured by syntax). I would certainly object to this.
But I do think the style in this PR is a bit more regular than e.g. (A)
@image_comparison(
["specgram_freqs.png", "specgram_freqs_linear.png",
"specgram_noise.png", "specgram_noise_linear.png"],
remove_text=True, tol=0.07, style="default")
def test_specgram():
"""Test axes.specgram in default (psd) mode."""
(now you do need to edit more things when adding new items to the list -- though the argument is not very strong)
or (B)
@image_comparison(["specgram_freqs.png", "specgram_freqs_linear.png",
"specgram_noise.png", "specgram_noise_linear.png"],
remove_text=True, tol=0.07, style="default")
def test_specgram():
"""Test axes.specgram in default (psd) mode."""
(losing ~10 characters worth of width on the left of the screen is just silly)
I don't mind changing everything to (A) if we can agree on that, though.
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.
There are many alternative patterns that would, in my view, fit comfortably with Python's basic principle of indentation. If (A) works for you, it is OK for 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.
done
There was a *lot* of repeated code in the tests... this shortens test_axes.py by ~10%(!)
de1ff2e
to
6ea5295
Compare
There was a lot of repeated code in the tests... this shortens
test_axes.py by ~10%(!)
PR Summary
PR Checklist