Skip to content
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

Add a helper to generate mathtext error strings. #23255

Merged
merged 1 commit into from
Jun 12, 2022

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 11, 2022

This also ensures consistency in the names in the error strings; see
e.g. changes in test_mathtext (the contents of \overline are indeed a
"body", not a "value").

Renaming "simple_group" to "opt_group" is not only to make definitions
of over/underset fit in a single line, but also because the name seems
semantically more meaningful too. (req_group, OTOH, is just for
conciseness.)

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@@ -1740,71 +1763,57 @@ def set_names_and_parse_actions():
p.overline = Forward()
p.overset = Forward()
p.placeable = Forward()
p.required_group = Forward()
p.req_group = Forward()
Copy link
Member

Choose a reason for hiding this comment

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

Is there an important reason for the abbreviation? I'd have gone with required_group and optional_group.

Copy link
Contributor Author

@anntzer anntzer Jun 12, 2022

Choose a reason for hiding this comment

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

This makes more of the definitions below fit in a single line (e.g. making the definitions of frac/dfrac/binom and overset/underset more clearly parallel each other). I can undo that if you feel strongly about it, though.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer the full name, because that's more readable. I think wrapping is not too bad for the mentioned cases:

       p.binom <<= cmd(
           r"\binom", p.reqired_group("num") + p.reqired_group("den"))

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

This also ensures consistency in the names in the error strings; see
e.g. changes in test_mathtext (the contents of `\overline` are indeed a
"body", not a "value").

Renaming "simple_group" to "optional_group" is semantically more
meaningful.
@oscargus oscargus merged commit af256b6 into matplotlib:main Jun 12, 2022
@anntzer anntzer deleted the mathtexterrors branch June 12, 2022 17:55
@oscargus oscargus added this to the v3.6.0 milestone Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants