Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove many unused variables in tests. #13957

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 1 commit into from
Apr 19, 2019
Merged

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

ax.set_title('aardvark')
ax.set_title('left', loc='left')
ax.set_title('right', loc='right')

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
@@ -1835,7 +1828,7 @@ def test_specgram_angle(self):
pad_to=self.pad_to_specgram,
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.

@@ -1851,7 +1844,7 @@ def test_specgram_phase(self):
pad_to=self.pad_to_specgram,
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.

@@ -100,11 +100,11 @@ def test_logscale_transform_repr():
# check that repr of log transform succeeds
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