This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
Make illegal path-like variable names when constructing a DataTree from a Dataset #314
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.
pre-commit run --all-files
- [ ] New functions/methods are listed inapi.rst
docs/source/whats-new.rst
Technical Note
Regarding
Hashable
vsstr
Dataset keysNote: DataTree keys are
Hashable
. I only check for slashes in the variable names if they are instance ofstr
.I never encountered a case (yet) where a Dataset keys are not
str
butHashable
in the broader case.We can imagine corner-cases where keys would be other types of
Hashable
, egPath
frompathlib
The choice I made is (1): only apply the check of slashes in the key if the key is an instance of
str
.Another choice (2)would be to project the
Hashable
space ontostr
space:str(variable_name)
(1) seems more conservative than (2) as I do not pretend to be able to get a string representation for any
Hashable
.