[x] Passes pre-commit run --all-files- [ ] New functions/methods are listed in api.rst
[ ] Changes are summarized in docs/source/whats-new.rst
Technical Note
Regarding Hashable vs str Dataset keys
Note: DataTree keys are Hashable. I only check for slashes in the variable names if they are instance of str.
I never encountered a case (yet) where a Dataset keys are not str but Hashable in the broader case.
We can imagine corner-cases where keys would be other types of Hashable, eg Path from pathlib
In [2]: from pathlib import Path
In [3]: hash(Path("/"))
Out[3]: -3809984204556177651
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 onto str 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.
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 notstr
butHashable
in the broader case. We can imagine corner-cases where keys would be other types ofHashable
, 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 theHashable
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 anyHashable
.