-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Move towards making texmanager stateless. #22725
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
I suggest to make all stateless functions classmethods to make it very clear that they do not depend on state. |
Good idea, done. |
for font_family in cls._font_families: | ||
if is_reduced_font and font_family == requested_family: | ||
preambles[font_family] = cls._font_preambles[ | ||
rcParams['font.family'][0].lower()] |
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.
Um, what is this? I thought rcParams['font.family']
is a string?!? Should this be
rcParams['font.family'][0].lower()] | |
rcParams['font.family'].lower()] |
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.
No, it's a list of strings:
matplotlib/lib/matplotlib/rcsetup.py
Line 914 in f670fe7
"font.family": validate_stringlist, # used by text object |
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.
Ah, I was checking
## The font.family property can take either a concrete font name (not supported |
and
#font.family: sans-serif |
We should make that clearer in matplotlibrc
.
And yes interestingly validate_stringlist
can make a list out of a single string. matplotlibrc
is less well-defined than I thought 😦.
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 could reasonably be tracked as a separate issue?
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.
Sure: #22746.
Previously, TexManager needed to call get_font_config at a specific place in the middle of processing to update some internal attributes before proceeding with TeX source generation. Instead, move towards making TexManager stateless (except for caching), i.e. the user facing API should be thought of as a bunch of independently callable functions `make_tex()`, `make_dvi()`, etc. (they will probably stay as methods on a "empty" TexManager object for a long time for backcompat, in fact).
Previously, TexManager needed to call get_font_config at a specific
place in the middle of processing to update some internal attributes
before proceeding with TeX source generation. Instead, move towards
making TexManager stateless (except for caching), i.e. the user facing
API should be thought of as a bunch of independently callable functions
make_tex()
,make_dvi()
, etc. (they will probably stay as methods ona "empty" TexManager object for a long time for backcompat, in fact).
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).