Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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 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!).
Case 1) is#9795 (backend-switching), where I propose that assigning torcParams["backend"]
also sets the backend (currently, this has no effect after pyplot is imported, but I believe havingrcParams["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 instanceis mpl.rcParams
.
Case 2) is#11231, where I propose replacing multiple rcParams (figure.subplot.{left,right,...}
) by a single one (figure.subplot
). During the deprecation period, changes tofigure.subplot.{left,right,...}
need to be propagated tofigure.subplot
in the same instance, and vice-versa.
Making 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".
Thoughts?
(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.)
Edit: 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.