8000 Py3fy mathtext.py. by anntzer · Pull Request #10520 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Py3fy mathtext.py. #10520

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
Feb 19, 2018
Merged

Py3fy mathtext.py. #10520

merged 1 commit into from
Feb 19, 2018

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Feb 17, 2018

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

@@ -464,8 +454,9 @@ def set_canvas_size(self, w, h, d):
Set the size of the buffer used to render the math expression.
Only really necessary for the bitmap backends.
"""
self.width, self.height, self.depth = ceil(w), ceil(h), ceil(d)
self.mathtext_backend.set_canvas_size(self.width, self.height, self.depth)
self.width, self.height, self.depth = map(np.ceil, [w, h, d])
Copy link
Member

Choose a reason for hiding this comment

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

Is this faster than np.ceil([w, h, d])?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

missed that, thanks.

self.width, self.height, self.depth = ceil(w), ceil(h), ceil(d)
self.mathtext_backend.set_canvas_size(self.width, self.height, self.depth)
self.width, self.height, self.depth = map(np.ceil, [w, h, d])
self.mathtext_backend.set_canvas_size(
Copy link
Member

Choose a reason for hiding this comment

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

Was this too long or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

Was there a pep8ignored defined that can be removed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's a bunch of other long lines, let's keep that for another pr.

warn("Substituting with a dummy symbol.", MathTextWarning)
warnings.warn(
"Font {!r} does not have a glyph for {!a} [U+{:x}], "
"Substituting with a dummy symbol.".format(
Copy link
Member

Choose a reason for hiding this comment

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

Lower case now.

@@ -1099,7 +1091,7 @@ def __init__(self, default_font_prop):

self.fonts['default'] = default_font
self.fonts['regular'] = default_font
self.pswriter = six.moves.cStringIO()
self.pswriter = cStringIO()
Copy link
Member

Choose a reason for hiding this comment

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

StringIO

.format(font.get_fontname(), sym), MathTextWarning)
warnings.warn(
"No glyph in standard Postscript font {!r} for {!r}"
.format(font.get_fontname(), sym), MathTextWarning)
Copy link
Member

Choose a reason for hiding this comment

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

Wrap second argument.

prev_char = s[loc-i]
if prev_char != ' ':
break
prev_char = next(c for c in s[:loc][::-1] if c != ' ')
Copy link
Member

Choose a reason for hiding this comment

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

It appears you need a default here.

@anntzer
Copy link
Contributor Author
anntzer commented Feb 18, 2018

comments handled

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.

Looks correct, but one of the Travis builders has what seems like a spurious error. I restarted the build to see if it goes away.

instead.
The following functions are deprecated:
- ``cbook.is_numlike`` (use ``isinstance(..., numbers.Number)`` instead)
- ``backend_pdf.unichr_safe`` (use ``chr`` instead)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that mathtext.unichr_safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

untypoed it

glue_spec = GlueSpec.factory(glue_type)
elif isinstance(glue_type, GlueSpec):
glue_spec = glue_type
else:
raise ValueError("glue_type must be a glue spec name or instance.")
raise ValueError("glue_type must be a glue spec name or instance")
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason for getting rid of the full stop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error messages (i.e. arguments to exceptions) typically don't contain a full stop, even if they are otherwise full sentences. e.g.

In [2]: f(1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-281ab0a37d7d> in <module>()
----> 1 f(1)

TypeError: f() takes 0 positional arguments but 1 was given

and Matplotlib mostly follows the same convention (no stats, just an empirical observation).

@dstansby dstansby merged commit a94f839 into matplotlib:master Feb 19, 2018
@anntzer anntzer deleted the py3mathtext branch February 19, 2018 14:50
@QuLogic QuLogic added this to the v3.0 milestone Feb 19, 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.

5 participants
0