Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
timhoffm merged 1 commit into matplotlib:master from anntzer:rc_ctxd
Mar 24, 2020

Conversation

Copy link
Contributor

@anntzer anntzer commented Sep 19, 2019

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.
(https://github.com/matplotlib/matplotlib/pull/11896/files#diff-9ffb0d1db51a67ee4f37528e00715b3cR852)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

pharshalp reacted with hooray emoji
@anntzer anntzer force-pushed the rc_ctxd branch 3 times, most recently from 1de49b3 to 44b8a4b Compare September 19, 2019 14:02
Copy link
Member

Even with the usage pattern staying the same, is this an API change (rc_context now being a function instead of a class)?

Copy link
Contributor Author

anntzer commented Sep 21, 2019

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.

Copy link
Member

We have never publicly mentioned that rc_context was a class. It looked like a function https://matplotlib.org/api/matplotlib_configuration_api.html#matplotlib.rc_context

So from my point of view, this does not need additional documentation.

Copy link
Contributor Author

anntzer commented Mar 24, 2020

so good to go, then?

Copy link
Member

QuLogic commented Mar 24, 2020

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.
Copy link
Contributor Author

anntzer commented Mar 24, 2020

I rebased and retriggered a build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@QuLogic QuLogic QuLogic approved these changes

@dstansby dstansby dstansby left review comments

@timhoffm timhoffm timhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.3.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /