-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make it possible to use rc_context as a decorator. #15303
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
1de49b3
to
44b8a4b
Compare
Even with the usage pattern staying the same, is this an API change ( |
Well, it's noted as an API change though that specific point is not made explicit; I'm not sure going more into the technical details is going to help legibility of the changelog, but can do so if you insist. |
We have never publicly mentioned that So from my point of view, this does not need additional documentation. |
so good to go, then? |
Yes, but I don't know what's wrong with tests as the link is broken. |
See changelog note. There are also other advantages with contextmanager, e.g. reusing a context multiple times works ``` ctx = rc_context(...) with ctx: ... # in the context ... # out of the context with ctx: ... # in the context again ``` (with a test for the decorator form, which is equivalent) but in practice this will often run into the issue of early/late resolution of rcParams, so I didn't mention it in the changelog. xkcd() still needs to be implemented manually in terms of `__enter__`/`__exit__` but at least we know that creation of the contextmanager cannot fail, so things are simpler. Also we don't need to check for whether the backend has been resolved because rcParams now just prevent re-setting the backend to auto_backend_sentinel.
I rebased and retriggered a build. |
See changelog note.
There are also other advantages with contextmanager, e.g. reusing a
context multiple times works
(with a test for the decorator form, which is equivalent) but in
practice this will often run into the issue of early/late resolution of
rcParams, so I didn't mention it in the changelog.
xkcd() still needs to be implemented manually in terms of
__enter__
/__exit__
but at least we know that creation of thecontextmanager cannot fail, so things are simpler.
Also we don't need to check for whether the backend has been
resolved because rcParams now just prevent re-setting the backend to
auto_backend_sentinel.
(https://github.com/matplotlib/matplotlib/pull/11896/files#diff-9ffb0d1db51a67ee4f37528e00715b3cR852)
PR Summary
PR Checklist