Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate public access to many mathtext internals. #18378

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
Sep 17, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 30, 2020

For most of these classes, there isn't really a "reasonable" way to use
them via public API anyways.

  • Fonts subclasses are looked up via the private _font_type_mapping
    and extending that would require adding new entries for
    rcParams["mathtext.fontset"].
  • FontConstantsBase\s are looked up via the private
    _font_constant_mapping.
  • Node and its subclasses are clearly internal constructs of the
    mathtext parser (technically, they are visible to MathtextBackend
    subclasses when their render method is called, but one cannot
    register new MathtextBackend subclasses either as that happens via
    the private _backend_mapping).
  • Ship is just an implementation detail for the ship callable, which
    can only be called on a Node or in a MathtextBackend, neither of
    which are really public per the above.
  • Parser is set up and driven via the (still public) MathTextParser.
  • Error, SHRINK_FACTOR, GROW_FACTOR, NUM_SIZE_LEVELS are helpers
    for the parser.
  • latex_to_*, stix_virtual_fonts, tex2uni are helper lookup tables
    for the fonts. (tex2uni stays indirectly accessible via the
    get_unicode_index, which basically performs lookup on it.)

Making these private should simplify the implementation of various
improvements to mathtext, e.g. better support for math fonts, as well as
code cleanups.

We can later decide how to properly expose these internals (e.g. #9165).

See also #16181.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • 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).

@anntzer anntzer added this to the v3.4.0 milestone Aug 30, 2020
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Conditional on CI passing.

@anntzer anntzer force-pushed the private-mathtext branch 3 times, most recently from f764aae to ca81014 Compare September 3, 2020 08:20
@anntzer
Copy link
Contributor Author

anntzer commented Sep 3, 2020

I decided to also make ship private (now listed above).

@anntzer anntzer force-pushed the private-mathtext branch 2 times, most recently from 336a702 to 130d7ca Compare September 4, 2020 08:40
@@ -195,6 +200,70 @@
"dviread.PsfontsMap": [
"lib/matplotlib/dviread.py:docstring of matplotlib.dviread.DviFont:20"
],
"matplotlib._mathtext.Box": [
"doc/api/mathtext_api.rst:11",
Copy link
Member

Choose a reason for hiding this comment

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

It makes more sense to update these references, or delete them, rather than start accepting them as missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that (AFAICT) at least they will always show up in the SVG inheritance diagram. I got rid of the other occurrences, though.

For most of these classes, there isn't really a "reasonable" way to use
them via public API anyways.

- `Fonts` subclasses are looked up via the private `_font_type_mapping`
  and extending that would require adding new entries for
  `rcParams["mathtext.fontset"]`.
- `FontConstantsBase`\s are looked up via the private
  `_font_constant_mapping`.
- `Node` and its subclasses are clearly internal constructs of the
  mathtext parser (technically, they are visible to `MathtextBackend`
  subclasses when their `render` method is called, but one cannot
  register new `MathtextBackend` subclasses either as that happens via
  the private `_backend_mapping`).
- `Ship` is just an implementation detail for the `ship` callable, which
  can only be called on a `Node` or in a `MathtextBackend`, neither of
  which are really public per the above.
- `Parser` is set up and driven via the (still public) `MathTextParser`.
- `Error`, `SHRINK_FACTOR`, `GROW_FACTOR`, `NUM_SIZE_LEVELS` are helpers
  for the parser.
- `latex_to_*`, `stix_virtual_fonts`, `tex2uni` are helper lookup tables
  for the fonts.  (`tex2uni` stays indirectly accessible via the
  `get_unicode_index`, which basically performs lookup on it.)

Making these private should simplify the implementation of various
improvements to mathtext, e.g. better support for math fonts, as well as
code cleanups.
@QuLogic QuLogic merged commit ffd9767 into matplotlib:master Sep 17, 2020
@anntzer anntzer deleted the private-mathtext branch September 17, 2020 00:30
@anntzer anntzer mentioned this pull request Jan 28, 2021
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.

4 participants