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

Dedupe spectral plotting tests. #16444

Merged
merged 1 commit into from Feb 10, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 8, 2020

There was a lot of repeated code in the tests... this shortens
test_axes.py by ~10%(!)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

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

@image_comparison([
"specgram_freqs.png", "specgram_freqs_linear.png",
"specgram_noise.png", "specgram_noise_linear.png",
], remove_text=True, tol=0.07, style="default")
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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%(!)
@jklymak jklymak merged commit e9f3459 into matplotlib:master Feb 10, 2020
@anntzer anntzer deleted the spectral-plotting-tests branch February 10, 2020 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants