Title: On making the rc-validators function know the rcParam affected instance · Issue #11509 · matplotlib/matplotlib · GitHub
Open Graph Title: On making the rc-validators function know the rcParam affected instance · Issue #11509 · matplotlib/matplotlib
X Title: On making the rc-validators function know the rcParam affected instance · Issue #11509 · matplotlib/matplotlib
Description: The RcParams class is probably treated as a singleton (with rcParams as the sole instance) by nearly everyone. I now have two cases where I either need to rely on this assumption, or at least need to make a rc-validator function know the...
Open Graph Description: The RcParams class is probably treated as a singleton (with rcParams as the sole instance) by nearly everyone. I now have two cases where I either need to rely on this assumption, or at least need ...
X Description: The RcParams class is probably treated as a singleton (with rcParams as the sole instance) by nearly everyone. I now have two cases where I either need to rely on this assumption, or at least need ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/11509
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"On making the rc-validators function know the rcParam affected instance","articleBody":"The RcParams class is probably treated as a singleton (with rcParams as the sole instance) by nearly everyone. I now have two cases where I either need to rely on this assumption, or at least need to make a rc-validator function know the actual RcParam instance that is being modified (if RcParam is a singleton, then we of course know what instance is being modified -- there's only one instance!).\r\n\r\nCase 1) is #9795 (backend-switching), where I propose that assigning to `rcParams[\"backend\"]` also sets the backend (currently, this has no effect after pyplot is imported, but I believe having `rcParams[\"backend\"]` and the actual backend go out of sync is particularly bad in a world where backend-switching becomes better supported). But of course, the actual backend in use is global state, so the backend switch (which is implemented in the rc-validator function) should only occur if the currently modified instance `is mpl.rcParams`.\r\n\r\nCase 2) is #11231, where I propose replacing multiple rcParams (`figure.subplot.{left,right,...}`) by a single one (`figure.subplot`). During the deprecation period, changes to `figure.subplot.{left,right,...}` need to be propagated to `figure.subplot` in the same instance, and vice-versa.\r\n\r\nMaking rcParams a singleton (for most purposes) is not particularly difficult (override `__new__`, yada yada) but perhaps inelegant? Making the validators know the currently modified instance is not too hard either, as all validators currently take a single argument (and no optional argument), so we can just say e.g. \"if a validator takes two arguments (this can easily be checked at the very beginning), pass the RcParams instance as first/second argument\".\r\n\r\nThoughts?\r\n\r\n(Milestoning as 3.0 as it would be nice to resolve this before #9795, but that's not strictly necessary either as we can just make/document the assumption too.)\r\n\r\nEdit: dates.converter and dates.interval_multiples are also entries that now assume that there's just a single rcParams instance, as assigning to them (regardless of whether it's on the main instance or not) always updates the global state regarding date formatters.","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2018-06-26T00:17:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/11509/matplotlib/issues/11509"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:da194b2a-3654-d9b0-69f8-1d061fe90c82 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E02:1DC0B7:6EAD52:9857A4:6A538778 |
| html-safe-nonce | ae3b268ce2d6ffd8288a204a8f29a85ee81c2a7a75241c1ee7bd568c7eb3aca6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTAyOjFEQzBCNzo2RUFENTI6OTg1N0E0OjZBNTM4Nzc4IiwidmlzaXRvcl9pZCI6IjYyMDYxNTcyODAxNDUyNjMyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e3c8f16e8f46635079cdd5288c0acf2bc2b9204a58d63f5ec74f45eca9ce8ddb |
| hovercard-subject-tag | issue:335612826 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/11509/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30d213e4021683761541ec9446c3dbc85ecca33f9c23ad057c6f40fddb9a16c6/matplotlib/matplotlib/issues/11509 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30d213e4021683761541ec9446c3dbc85ecca33f9c23ad057c6f40fddb9a16c6/matplotlib/matplotlib/issues/11509 |
| og:image:alt | The RcParams class is probably treated as a singleton (with rcParams as the sole instance) by nearly everyone. I now have two cases where I either need to rely on this assumption, or at least need ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width