Add parse_math in Text and default it False for TextBox#20367
Add parse_math in Text and default it False for TextBox#20367QuLogic merged 10 commits intomatplotlib:masterfrom
Conversation
tacaswell
left a comment
There was a problem hiding this comment.
👍 to theory of the implementation
Needs a better name and to be added at the end of the parameter list.
Should also get a test, maybe write $$ to SVG and make sure the text is actually in the svg?
|
Anyone can dismiss my review. |
How about just catching an error? Probably simpler and will save us space: import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.text(0, 0, r"$ \wrong{5} $", override_math=True)
fig.canvas.draw() # won't throw error
ax.text(0, 0, r"$ \wrong{5} $", override_math=False)
fig.canvas.draw() # will throw error^with the right parameter name, ofcourse. |
|
Do we not test widgets like TextBox? |
|
If we don't, then you can be the first to add them. 😛 |
|
I would suggest e.g. |
|
But |
|
Fair enough, I don't have a very strong opinion there... |
|
|
jklymak
left a comment
There was a problem hiding this comment.
This looks good to me. Probably needs a what's-new entry though since this is new API
2c06e48 to
6a6a51e
Compare
Test added, and parameter was renamed.
PR Summary
Following up the comment: #20266 (comment), this PR adds a
override_mathto Text objects, and make TextBox's text object default it to True.This resolves #20266.
It does not allow GUI to go in invalid state when there's invalid mathtext in it, because it isn't parsed at all.
(also allows folks to override mathtext at all in their text objects)
Interactive trial:
Static trial:
Needs a changenote (API change) and tests, but let's wait for a review before that.
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).