8000 Use consistent float-to-str formatting for tests with units by QuLogic · Pull Request #10052 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Use consistent float-to-str formatting for tests with units #10052

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
Dec 21, 2017

Conversation

QuLogic
Copy link
Member
@QuLogic QuLogic commented Dec 20, 2017

PR Summary

Adding explicit formatting should ensure that the resulting image is always the same. At the very least, this seems to affect Python 2 on Fedora Rawhide (which is a bit odd, TBH, since Py2 is tested on Travis) and hopefully fixes nightly builds too.

PR Checklist

  • Has Pytest style unit tests
  • [mostly] Code is PEP 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

@QuLogic
Copy link
Member Author
QuLogic commented Dec 20, 2017

Looks like this does fix nightly.

Copy link
Member
@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

This looks good to me. Though a pretty obscure corner of the code base...

@@ -36,12 +36,12 @@ def __call__( self, x, pos = None ):
if len(self.locs) == 0:
return ''
else:
return str(x)
return '{:.12g}'.format(x)
Copy link
Contributor

Choose a reason for hiding this comment

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

Using ".12" instead of ".12g" would keep the ".0" in the test images, and perhaps avoid the need to change some of them?

Copy link
Member Author

Choose a reason for hiding this comment

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

You might be right, but let's see how the nightly build feels about it.

@QuLogic
8000
Copy link
Member Author
QuLogic commented Dec 21, 2017

Looks like we're good for Fedora 28 and a nightly build.

@anntzer anntzer merged commit 6ea7dc7 into matplotlib:master Dec 21, 2017
lumberbot-app bot pushed a commit that referenced this pull request Dec 21, 2017
@QuLogic QuLogic deleted the unit-tests branch December 21, 2017 20:29
QuLogic added a commit that referenced this pull request Dec 21, 2017
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.

3 participants
0