You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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.match should be renamed to DataTree.glob
Add a new method DataTree.match that returns a boolean like PurePath.match does
DataTree.lineage should be renamed to .parents
Add an .is_relative_to method (this is deprecated in pathlib)
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 ofpathlib.PurePath
objects. I think this aligning of APIs/nomenclature is a good idea. In general think it's conceptually useful to think of aDataTree
object as if it were an instance ofpathlib.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.match
should be renamed toDataTree.glob
DataTree.match
that returns a boolean likePurePath.match
doesDataTree.lineage
should be renamed to.parents
Add an(this is deprecated in.is_relative_to
methodpathlib
).joinpath
method could be usefulDataTree.relative_to
should possibly have awalk_up
method (see Use new walk_up parameter in pathlib for traversing relative paths xarray-contrib/datatree#258).with_name
method might be useful.with_segments
method might be usefulInspired by
pathlib.Path
(i.e. concrete paths):DataTree.walk
method might be a better way to expose the logic in iterators.py.rename
method might be useful.replace
method might be useful.rglob
method (though having this and.glob
seems overkill)Several of these might be useful abstractions internally, especially
.joinpath
,.walk
, and.replace
.EDIT: Let's also document this similarity:
api.rst
to have a sectionPath-like methods
The text was updated successfully, but these errors were encountered: