-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Py3fy mathtext.py. #10520
Conversation
lib/matplotlib/mathtext.py
Outdated
@@ -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]) |
There was a problem hiding this comment.
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])
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed that, thanks.
lib/matplotlib/mathtext.py
Outdated
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
lib/matplotlib/mathtext.py
Outdated
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lower case now.
lib/matplotlib/mathtext.py
Outdated
@@ -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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringIO
lib/matplotlib/mathtext.py
Outdated
.format(font.get_fontname(), sym), MathTextWarning) | ||
warnings.warn( | ||
"No glyph in standard Postscript font {!r} for {!r}" | ||
.format(font.get_fontname(), sym), MathTextWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap second argument.
lib/matplotlib/mathtext.py
Outdated
prev_char = s[loc-i] | ||
if prev_char != ' ': | ||
break | ||
prev_char = next(c for c in s[:loc][::-1] if c != ' ') |
There was a problem hiding this comment.
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.
comments handled |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
PR Summary
PR Checklist