-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Align datatree to_dict
and from_dict
to similar methods on Dataset
and DataArray
level
#9080
Open
etienneschalk
wants to merge
21
commits into
pydata:main
Choose a base branch
from
etienneschalk:eschalk/align-datatree-to_dict-to-existing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Align datatree to_dict
and from_dict
to similar methods on Dataset
and DataArray
level
#9080
etienneschalk
wants to merge
21
commits into
pydata:main
from
etienneschalk:eschalk/align-datatree-to_dict-to-existing
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57ad774
to
c0a6558
Compare
etienneschalk
commented
Jun 8, 2024
7173eac
to
b93b97e
Compare
to_dict
and from_dict
to similar methods on Dataset
and DataArray
levelto_dict
and from_dict
to similar methods on Dataset
and DataArray
level
2147def
to
a248296
Compare
e0137b0
to
7e621a7
Compare
9598f25
to
8a84cdc
Compare
for more information, see https://pre-commit.ci
…om:etienneschalk/xarray into eschalk/align-datatree-to_dict-to-existing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
from_dict
andto_dict
behaviours to their Dataset equivalents #9074whats-new.rst
api.rst
to_native_dict
andfrom_native_dict
This Pull Request adds two new methods on the DataTree class:
to_native_dict
andfrom_native_dict
.~~The existing ones are renamed to
to_paths_dict
andfrom_paths_dict
, as their working data structure is a dict of paths to xarray data structures. ~~DataTree.from_dict
->DataTree.from_paths_dict
DataTree.to_dict
->DataTree.to_paths_dict
The goal is to convert back-and-forth DataTrees to Python dictionaries, with the final goal (left to the user) of dumping these dictionaries to JSON, and read back JSON to a DataTree. The motive is exposed in #9074
Open Points
(1)
Since theDataTree.to_dict
andDataTree.from_dict
already exist on DataTree, but with a different behaviour, this change is a breaking change. I think it is needed for having a behaviour similar on the existing Dataset methods.However, if the current usage offrom_dict
andto_dict
is already so widespread that it cannot be renamed easily, then an option can be added to thefrom_dict
andto_dict
methods to switch between the current behaviour (convert a mapping of str paths to xarray objets to a DataTree) and the new (convert to a recursive dict with no left xarray structure, delegating lower-lever conversion of datasets toDataset.to_dict
andDataset.from_dict