MCPcopy Index your code
hub / github.com/pydata/xarray / DataTree

Class DataTree

xarray/core/datatree.py:462–2685  ·  view source on GitHub ↗

A tree-like hierarchical collection of xarray objects. Attempts to present an API like that of xarray.Dataset, but methods are wrapped to also update all the tree's child nodes.

Source from the content-addressed store, hash-verified

460
461
462class DataTree(
463 NamedNode,
464 DataTreeAggregations,
465 DataTreeOpsMixin,
466 TreeAttrAccessMixin,
467 Mapping[str, "DataArray | DataTree"],
468):
469 """
470 A tree-like hierarchical collection of xarray objects.
471
472 Attempts to present an API like that of xarray.Dataset, but methods are wrapped to also update all the tree's child nodes.
473 """
474
475 # TODO Some way of sorting children by depth
476
477 # TODO do we need a watch out for if methods intended only for root nodes are called on non-root nodes?
478
479 # TODO dataset methods which should not or cannot act over the whole tree, such as .to_array
480
481 # TODO .loc method
482
483 # TODO a lot of properties like .variables could be defined in a DataMapping class which both Dataset and DataTree inherit from
484
485 # TODO all groupby classes
486
487 # TODO a lot of properties like .variables could be defined in a DataMapping class which both Dataset and DataTree inherit from
488
489 # TODO all groupby classes
490
491 _name: str | None
492 _parent: DataTree | None
493 _children: dict[str, DataTree]
494 _cache: dict[str, Any] # used by _CachedAccessor
495 _data_variables: dict[Hashable, Variable]
496 _node_coord_variables: dict[Hashable, Variable]
497 _node_dims: dict[Hashable, int]
498 _node_indexes: dict[Hashable, Index]
499 _attrs: dict[Hashable, Any] | None
500 _encoding: dict[Hashable, Any] | None
501 _close: Callable[[], None] | None
502
503 __slots__ = (
504 "_attrs",
505 "_cache", # used by _CachedAccessor
506 "_children",
507 "_close",
508 "_data_variables",
509 "_encoding",
510 "_name",
511 "_node_coord_variables",
512 "_node_dims",
513 "_node_indexes",
514 "_parent",
515 )
516
517 def __init__(
518 self,
519 dataset: Dataset | Coordinates | None = None,

Callers 15

merge_treesFunction · 0.90
test_load_datatreeMethod · 0.90
test_open_netcdf3Method · 0.90
test_emptyMethod · 0.90
test_nameMethod · 0.90
test_bad_namesMethod · 0.90
test_data_argMethod · 0.90
test_path_propertyMethod · 0.90
test_path_roundtripMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_load_datatreeMethod · 0.72
test_open_netcdf3Method · 0.72
test_emptyMethod · 0.72
test_nameMethod · 0.72
test_bad_namesMethod · 0.72
test_data_argMethod · 0.72
test_path_propertyMethod · 0.72
test_path_roundtripMethod · 0.72
test_same_treeMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…