-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
API designenhancementtopic-DataTreeRelated to the implementation of a DataTree classRelated to the implementation of a DataTree class
Description
What is your issue?
Copied from xarray-contrib/datatree#283
@eschalkargans suggested in #281 that the API of DataTree objects could more closely follow that of pathlib.PurePath objects. I think this aligning of APIs/nomenclature is a good idea. In general think it's conceptually useful to think of a DataTree object as if it were an instance of pathlib.PurePosixPath (even though the actual implementation should not work like that).
There are various methods we might want to add/change to make them more compatible:
Inspired by pathlib.PurePath:
-
DataTree.matchshould be renamed toDataTree.glob - Add a new method
DataTree.matchthat returns a boolean likePurePath.matchdoes -
DataTree.lineageshould be renamed to.parents -
Add an(this is deprecated in.is_relative_tomethodpathlib) - A new
.joinpathmethod could be useful -
DataTree.relative_toshould possibly have awalk_upmethod (see Use new walk_up parameter in pathlib for traversing relative paths xarray-contrib/datatree#258) - A new
.with_namemethod might be useful - A new
.with_segmentsmethod might be useful
Inspired by pathlib.Path (i.e. concrete paths):
- A new
DataTree.walkmethod might be a better way to expose the logic in iterators.py - A new
.renamemethod might be useful - A new
.replacemethod might be useful - A new
.rglobmethod (though having this and.globseems overkill)
Several of these might be useful abstractions internally, especially .joinpath, .walk, and .replace.
EDIT: Let's also document this similarity:
- Add section to documentation explicitly pointing out this alignment of APIs (#287)
- Reorganise
api.rstto have a sectionPath-like methods
Metadata
Metadata
Assignees
Labels
API designenhancementtopic-DataTreeRelated to the implementation of a DataTree classRelated to the implementation of a DataTree class