Skip to content
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

Some more f-strings. #13940

Merged
merged 1 commit into from Jun 8, 2019
Merged

Some more f-strings. #13940

merged 1 commit into from Jun 8, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Apr 12, 2019

"..." % locals() is perhaps the construct that f-strings most
obviously replace, so let's do that replacement.

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

@tacaswell tacaswell added this to the v3.2.0 milestone Apr 20, 2019
/BBox[0 0 %(sidelen)d %(sidelen)d]
/XStep %(sidelen)d
/YStep %(sidelen)d
/BBox[0 0 {sidelen} {sidelen}]
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to be defensive and keep the formatting information?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that they're numbers (d) rather than something else? if anything passing the wrong value seems more likely to happen than passing the wrong type.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't see that sidelen = 72 is hard coded just a few lines before. So the risk is actually only in a later code change.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's a small risk, but it's much easier to debug a Python TypeError than a broken postscript file. Postscript and pdf viewers don't really show very good error messages.

@efiring
Copy link
Member

efiring commented May 26, 2019

@anntzer I'm neutral with regard to keeping the formatting, but given @tacaswell's question and @timhoffm's response, I suggest you put it in, at which point I will merge. It (the format specs) can't hurt, right?

@anntzer
Copy link
Contributor Author

anntzer commented May 27, 2019

I'd rather leave things as they are (we wouldn't be adding that type info if we were writing that code from scratch, after all) but will include the type info if either @tacaswell or @timhoffm reply here that they really want them :)

/BBox[0 0 %(sidelen)d %(sidelen)d]
/XStep %(sidelen)d
/YStep %(sidelen)d
/BBox[0 0 {sidelen} {sidelen}]
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see that sidelen = 72 is hard coded just a few lines before. So the risk is actually only in a later code change.

`"..." % locals()` is perhaps *the* construct that f-strings most
obviously replace, so let's do that replacement.
@anntzer
Copy link
Contributor Author

anntzer commented Jun 7, 2019

I gave in and added type info :)
Note that previously they were not even present everywhere, e.g. sometimes x and y are %(x)f and sometimes they are %(x)s. I harmonized them to {x:f}.

Copy link
Member

@jkseppan jkseppan left a comment

Choose a reason for hiding this comment

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

Thanks!

@timhoffm timhoffm merged commit 98490c4 into matplotlib:master Jun 8, 2019
@anntzer anntzer deleted the morefstrings branch June 8, 2019 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants