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

Data access API for rcParams#24730

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ksunden merged 1 commit intomatplotlib:mainfromtimhoffm:rcparams-data-api
Dec 23, 2022

Conversation

timhoffm
Copy link
Member

@timhoffmtimhoffm commentedDec 14, 2022
edited
Loading

PR Summary

Replaces (first step of)#12577, see in particular#12577 (comment).

This provides a defined API for accessing rcParams viarcParams._data[key] while circumventing any validation logic happening inrcParams[key].

Before, direct data access was realized throughdict.__getitem__(rcParams, key) /dict.__setitem__(rcParams, key, val), which depends on the implementation detail ofrcParams being a dict subclass. The new data access API gets rid of this dependency and thus opens up a way to later move away from dict subclassing.

We want to move away from dict subclassing and only guarantee theMutableMapping interface forrcParams in the future. This allows other future restructings like introducing a new configuration management and changingrcParams into a backward-compatible adapter.

Ping@anntzer who will be affected by this change in mplcairo#12577 (comment)

@anntzer
Copy link
Contributor

anntzer commentedDec 14, 2022
edited
Loading

Thanks for the ping. The replacement seems OK, but perhaps you could just make the APIrcParams._get(key) andrcParams._set(key, value) which avoids introducing another private helper class and can just be done with plain methods? (Also youcould mark the methods with:meta public: so that they show up in the rendered docs, seehttps://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html)

story645 reacted with thumbs up emoji

@timhoffmtimhoffmforce-pushed thercparams-data-api branch 2 times, most recently frome8ff5bb to888811cCompareDecember 15, 2022 10:37
Copy link
Member

@oscargusoscargus left a comment

Choose a reason for hiding this comment

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

Some minor comments. Looks good, but I guess other people have better insights into what is actually wanted.

@@ -605,7 +605,7 @@ def gen_candidates():
)
class RcParams(MutableMapping, dict):
Copy link
Member

Choose a reason for hiding this comment

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

I may not fully get the scope here, but I take it that one reason to do this is that we should not subclass fromdict later on? Or is the whole idea to provide a stable API for this, but actually still subclass?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We want to get rid of dict subclassing eventually. Using a dict subclass dictates the internal data model. We likely don't want this in the future when we're remodelling the config data structure. Either the new structure will be a 100% API compatible drop in and the config object will be available viarcParams; or we have a new completely free to designconfig object andrcParams will loose all state and only be an adapter to that newconfig object. Either way, being bound to a dict subclass would be cumbersome.

tacaswell reacted with thumbs up emoji
@jklymak
Copy link
Member

I guess I don't fully understand the need for this change, even after reading the comments before. Is there some reason_set and_get wouldn't just be aliased to__setitem__ and__getitem__ in the new class, even without subclassingdict?

@jklymak
Copy link
Member

Note CI didn't run for this.

@tacaswell
Copy link
Member

Discussed on call, consensus is that while_get and_set are good ideas, we should refrain from making any major changes to the current implementation until we have a better idea what we want to replace it with.

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

Sorry, I didn't grok that this was callingdict.__get_item__, and hence didn't understand the point of this. I now understand and think it is a reasonable thing to add direct private access without hacking up an inheritance level todict. Added a few more clarifying phrases to the note that would have helped me.

Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

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

Have no objection on adding a shim/translation layer, especially if it's kept private 'til an API gets settled on - mostly just documentation nits about how this is communicating that this is a "don't touch, for contributors only" API.

This provides a defined API for accessing rcParams via`rcParams._data[key]`while circumventing any validation logic happening in`rcParams[key]`.Before, direct data access was realized through`dict.__getitem(rcParams, key)` / `dict.__setitem(rcParams, key, val)`,which depends on the implementation detail of `rcParams` being a dictsubclass. The new data access API gets rid of this dependence and thusopens up a way to later move away from dict subclassing.We want to move away from dict subclassing and only guarantee the`MutableMapping` interface for `rcParams` in the future. This allowsother future restructings like introducing a new configuration managementand changing `rcParams` into a backward-compatible adapter.Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>Co-authored-by: Jody Klymak <jklymak@gmail.com>Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>Co-authored-by: story645 <story645@gmail.com>
@ksundenksunden merged commit488962a intomatplotlib:mainDec 23, 2022
@timhoffmtimhoffm deleted the rcparams-data-api branchDecember 24, 2022 00:32
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@jklymakjklymakjklymak left review comments

@oscargusoscargusoscargus left review comments

@tacaswelltacaswelltacaswell approved these changes

@story645story645story645 approved these changes

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

Successfully merging this pull request may close these issues.

8 participants
@timhoffm@anntzer@jklymak@tacaswell@QuLogic@story645@oscargus@ksunden

[8]ページ先頭

©2009-2025 Movatter.jp