Skip to content

Rely a bit more on rc_context. #10913

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
Mar 29, 2018
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 28, 2018

PR Summary

Not really an argument for the PR, but note that (unusually), the contextmanager form is much faster:

In [5]: %timeit _orig = plt.rcParams.copy(); pass; plt.rcParams.update(_orig)
633 µs ± 3.87 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [6]: %timeit with plt.rc_context(): pass
14.6 µs ± 578 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

I believe (haven't profiled it) that's because plt.rc_context() intentionally doesn't revalidate the original rcs when restoring them.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 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

@anntzer anntzer added this to the v3.0 milestone Mar 28, 2018
'\\usepackage{sfmath}']})
tol = (6, 0)
original_params = mpl.rcParams.copy()
rc_sets = [{'font.family': 'sans-serif',
Copy link
Member

Choose a reason for hiding this comment

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

Could actually be a parametrized test. But I don't require it as part of this PR.

@dopplershift dopplershift merged commit 00ae375 into matplotlib:master Mar 29, 2018
@anntzer anntzer deleted the rc_context branch March 29, 2018 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants