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

Function diff_treestructure

xarray/core/formatting.py:1097–1111  ·  view source on GitHub ↗

Return a summary of why two trees are not isomorphic. If they are isomorphic return None.

(a: DataTree, b: DataTree)

Source from the content-addressed store, hash-verified

1095
1096
1097def diff_treestructure(a: DataTree, b: DataTree) -> str | None:
1098 """
1099 Return a summary of why two trees are not isomorphic.
1100 If they are isomorphic return None.
1101 """
1102 # .group_subtrees walks nodes in breadth-first-order, in order to produce as
1103 # shallow of a diff as possible
1104 for path, (node_a, node_b) in group_subtrees(a, b):
1105 if node_a.children.keys() != node_b.children.keys():
1106 path_str = "root node" if path == "." else f"node {path!r}"
1107 child_summary = f"{list(node_a.children)} vs {list(node_b.children)}"
1108 diff = f"Children at {path_str} do not match: {child_summary}"
1109 return diff
1110
1111 return None
1112
1113
1114def diff_dataset_repr(a, b, compat):

Callers 2

isomorphicMethod · 0.90
diff_datatree_reprFunction · 0.85

Calls 2

group_subtreesFunction · 0.90
keysMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…