-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove many unused variables. #13932
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
Conversation
041ddf1
to
088dbe1
Compare
I'd be nervous about removing any of these that don't have coverage in the test suite, lets see what happens though. |
@@ -0,0 +1,5 @@ | |||
Stricter parsing of the Composites section of AFM files |
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.
The PR title and commit message suggest that it does not have any effect on running code. However, here you state an API change. I'd feel much safer if this was a separate PR, not least because this PR is large.
Reverted the changes to afm.py. |
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.
IMHO this PR is too big, and thus makes reviewing difficult. I just got 1/3 though and then had to stop for doing other things. My motivation to take it up again is quite low.
For reviewing it's better to have multiple smaller PRs. You could just do it for a limited number of files in the first step.
|
||
# This only affects axes in first column and second row as share_all = | ||
# False. | ||
ax.imshow(Z, extent=extent, interpolation="nearest") |
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 loosely recall that there was a discussion if examples should have return values even though they are not used.
Advantage: The user sees that this returns an object that can be used further.
Disadvantage: In practical use, you would only define the return value if you actually need it. So the example does not represent how you would use Matplotlib in real life. And it's more cluttered than need be.
Personally, I'm fine with removing.
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 hope no one is reading axes_grid demos to learn about basic mpl concepts such as artists being returned by most calls :)
lib/matplotlib/dviread.py
Outdated
@@ -455,7 +455,7 @@ def _fnt_def_real(self, k, c, s, d, a, l): | |||
|
|||
@_dispatch(247, state=_dvistate.pre, args=('u1', 'u4', 'u4', 'u4', 'u1')) | |||
def _pre(self, i, num, den, mag, k): | |||
comment = self.file.read(k) | |||
self.file.read(k) # comment |
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 change removes semantics. Either use _comment = ...
or make the comment message more clear.
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.
that variable is not used, this is just reading a comment and throwing it away. slightly edited the comment about the comment :)
Sounds fair re: PR size; split out changes to tests (which are actually the majority of changes) to #13957. |
attrib = {} | ||
# Must add "px" to workaround a Firefox bug | ||
style['font-size'] = short_float_fmt(fontsize) + 'px' | ||
style['font-family'] = str(fontfamily) | ||
style['font-size'] = short_float_fmt(prop.get_size()) + 'px' |
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.
.get_size_in_points
and .get_size
are methods with identical bodies....
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 know... planning to deprecate get_size_in_points but there are bugger issues with fontproperties anyways.
I think this has gotten much smaller from when @timhoffm first reviewed it. |
@@ -582,7 +582,7 @@ def configure_subplots(self, button): | |||
toolfig = Figure(figsize=(6, 3)) | |||
canvas = self._get_canvas(toolfig) | |||
toolfig.subplots_adjust(top=0.9) | |||
tool = SubplotTool(self.canvas.figure, toolfig) | |||
SubplotTool(self.canvas.figure, toolfig) |
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.
The question this raises is, what keeps the SubplotTool instance alive when no reference to it is saved--not even until the end of this method? Presumably something external does get a reference, and I just don't see it. Otherwise, even without this change, the reference would last only until the end of the method.
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 also don't see who is holding the reference.
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.
It's actually a bit curious because the Tool object needs to stay alive even after the function has exited (so that the callbacks are not garbage-collected), but it's not clear to me what makes this possible.
In any case I checked, we do need to maintain a referrence to tool in case e.g. a gc collect()ion occurs in the body of the function, so I reverted this change and left a comment.
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.
It would be good if we can find out who's holing the SubplotTool
reference. Otherwise, this looks ok.
2b3ce74
to
abd9b67
Compare
@@ -160,6 +160,7 @@ def prepare_configure_subplots(self): | |||
toolfig = Figure(figsize=(6, 3)) | |||
canvas = FigureCanvasMac(toolfig) | |||
toolfig.subplots_adjust(top=0.9) | |||
# Need to keep a reference to the tool. | |||
tool = SubplotTool(self.canvas.figure, toolfig) |
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.
tool = SubplotTool(self.canvas.figure, toolfig) | |
_tool = SubplotTool(self.canvas.figure, toolfig) |
The underscore prefix is commonly used as "intentionally unused"; e.g. Pycharm does not mark the variable as unused anymore with this change.
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.
sure, done
They can be detected by removing the exclusion of F841 in .flake8. Some other unused variables have been left in, either for symmetry in the code or because their lack of use may possibly indicate a bug that needs to be investigated.
They can be detected by removing the exclusion of F841 in .flake8.
AFM parsing was made slightly stricter as a consequence (see changelog).
Some other unused variables have been left in, either for symmetry in
the code or because their lack of use may possibly indicate a bug that
needs to be investigated.
PR Summary
PR Checklist