Skip to content

Removed unused variables etc. #22160

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

Merged
merged 2 commits into from
Jan 10, 2022
Merged

Removed unused variables etc. #22160

merged 2 commits into from
Jan 10, 2022

Conversation

oscargus
Copy link
Member

@oscargus oscargus commented Jan 8, 2022

PR Summary

Some things pointed out by LGTM. Redundant assignments, unused variables etc.

PR Checklist

Tests and Styling

  • [N/A] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).

@@ -181,8 +181,6 @@ def subset_font(font_in, font_out, unicodes, opts):


def getsubset(subset, font_in):
subsets = subset.split('+')
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code below, my guess is that if 'menu' in subset should probably have been if 'menu' in subsets and so on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it probably was, but it works since subset is a string.

Tried to make a minimal change (and tried to search for the original code, but to no avail).

Copy link
Member

@timhoffm timhoffm Jan 9, 2022

Choose a reason for hiding this comment

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

+1 for changing the code below (or leaving as is for now with a comment if you don't dare to change it).

This code has been unchanged since it's addition in 2015, so there is no history to dig up.

Anyway, it's pretty obvious that this was an oversight and only accidentally worked. Checking subsets below is more clear, should be marginally faster, and is more safe in theory (even though it shouldn't make any practical difference for real use cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK! I'll change it. Both ways should work and using subsets is indeed probably more clear.

Copy link
Member

Choose a reason for hiding this comment

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

The if 'lang' in subset would be true if just lang-ext were in subset, but not now that we're checking subsets (which is correctly split). I don't know if this is a thing that might happen or if it's even going to be a problem, but this tool is internal anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are correct. One can probably find such cases.

@@ -7488,7 +7488,8 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
"""
cxy, freqs = mlab.cohere(x=x, y=y, NFFT=NFFT, Fs=Fs, detrend=detrend,
window=window, noverlap=noverlap,
scale_by_freq=scale_by_freq)
scale_by_freq=scale_by_freq, sides=sides,
Copy link
Member Author

Choose a reason for hiding this comment

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

My code analysis tool said that sides and pad_to was unused. I assume that they should be passed on (as otherwise these will not have any effect when calling cohere on an Axes).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that should be passed on. Seems it never worked, but nobody ever complained... You can correct this.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are passed on.

@timhoffm timhoffm added this to the v3.6.0 milestone Jan 10, 2022
@QuLogic QuLogic merged commit bedc202 into matplotlib:main Jan 10, 2022
@oscargus oscargus deleted the codecleanups branch January 11, 2022 10:10
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.

4 participants