-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add parse_math in Text and default it False for TextBox #20367
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
Conversation
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.
👍 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... |
|
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.
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_math
to 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
pytest
passes).flake8
on changed files to check).flake8-docstrings
and 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).