Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Join strings instead of adding them. #10332

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
Jan 28, 2018
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 27, 2018

See e.g. https://docs.python.org/3/library/functions.html#sum that
documents "".join as the preferred method (briefly, because summing (or
repeated addition) has quadratic complexity for strings).

side note:
https://github.com/takluyver/astsearch and https://github.com/hchasestevens/astpath are quite nice for this kind of cleanups...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • 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

@tacaswell tacaswell added this to the v2.2 milestone Jan 27, 2018
@tacaswell
Copy link
Member

That is exciting that we do not run any of those lines of code in the test suite!

writeln(self.fh,
r"\pgfsetdash{"
+ "".join(r"{%fpt}" % dash for dash in dash_list)
+ "r}{%fpt}" % dash_offset)
Copy link
Member

@timhoffm timhoffm Jan 27, 2018

Choose a reason for hiding this comment

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

588: "r: The r was a raw string qualifier before and seems to have slipped into the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cf @tacaswell's comment about none of this being tested :p
fixed

dash_str += r"{%fpt}" % dash
dash_str += r"}{%fpt}" % dash_offset
writeln(self.fh, dash_str)
writeln(self.fh,
Copy link
Member

Choose a reason for hiding this comment

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

On the danger of being pedantic, I would simply write

            dash_pattern = "".join(r"{%fpt}" % dash for dash in dash_list)
            writeln(self.fh,
                    r"\pgfsetdash{%s}{%fpt}" % (dash_pattern, dash_offset))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

See e.g. https://docs.python.org/3/library/functions.html#sum that
documents "".join as the preferred method (briefly, because summing (or
repeated addition) has quadratic complexity for strings).
@timhoffm timhoffm merged commit 2594eb6 into matplotlib:master Jan 28, 2018
@anntzer anntzer deleted the join-strings branch January 28, 2018 00:19
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
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.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.