Movatterモバイル変換


[0]ホーム

URL:


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

On making the rc-validators function know the rcParam affected instance #11509

Closed
@anntzer

Description

@anntzer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp