8000 Remove many unused variables in tests. by anntzer · Pull Request #13957 · matplotlib/matplotlib · GitHub < 8000 meta name="ui-target" content="full">
[go: up one dir, main page]

Skip to content

Conversation

@anntzer
Copy link
Contributor
@anntzer anntzer commented Apr 14, 2019

... as detected by enabling F841 in flake8.

A lot of these are instantiations of figures which are not used because
the test then uses the pyplot interface anyways; the figure doesn't need
to be explicitly instantiated as tests always run with no preexisting
figure (via an autouse fixture).

Split out from #13932 for reviewability.

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

@anntzer anntzer mentioned this pull request Apr 14, 2019
6 tasks
@tacaswell tacaswell added this to the v3.2.0 milestone Apr 15, 2019
ax = plt.subplot(4, 1, 4)
plt.hist(data_big, 100, histtype='stepfilled', log=True,
orientation='horizontal')
fig, axs = plt.subplots(4)
Copy link
Member

Choose a reason for hiding this comment

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

This puts an unused variable in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, fixed


assert 'left' == ax.get_title(loc='left')
assert 'right' == ax.get_title(loc='right')
assert 'aardvark' == ax.get_title(loc='center')
Copy link
Member

Choose a reason for hiding this comment

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

Probably should keep both versions of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, that was removed by mistake. restored.

Copy link
Member
@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

Minor concerns about touching the test suite in general, but looks ok.

I think some of those plt.figure calls were defensive from figure leaking between tests, but knowing when that isolation fails also seems useful.

@anntzer anntzer force-pushed the unused-tests branch 2 times, most recently from 26890ea to 2b3f5c5 Compare April 15, 2019 06:24
sides=self.sides,
mode='angle')
specm = np.mean(spec, axis=1)
np.mean(spec, axis=1)
Copy link
Member

Choose a reason for hiding this comment

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

That's doing nothing. specs is not modified and the return value is not used.

sides=self.sides,
mode='phase')
specm = np.mean(spec, axis=1)
np.mean(spec, axis=1)
Copy link
Member

Choose a reason for hiding this comment

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

Doing nothing.

fig, ax = plt.subplots()
ax.set_yscale('log')
s = repr(ax.transData)
repr(ax.transData)
Copy link
Member

Choose a reason for hiding this comment

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

Does nothing`? Or

Suggested change
repr(ax.transData)
repr(ax.transData) # smoke test that repr() succededs

... as detected by enabling F841 in flake8.

A lot of these are instantiations of figures which are not used because
the test then uses the pyplot interface anyways; the figure doesn't need
to be explicitly instantiated as tests always run with no preexisting
figure (via an autouse fixture).
@anntzer
Copy link
Contributor Author
anntzer commented Apr 17, 2019

thanks, comments handled

@efiring efiring merged commit 095caa1 into matplotlib:master Apr 19, 2019
@anntzer anntzer deleted the unused-tests branch April 20, 2019 07:24
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

0