Return a summary of why two trees are not isomorphic. If they are isomorphic return None.
(a: DataTree, b: DataTree)
| 1095 | |
| 1096 | |
| 1097 | def 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 | |
| 1114 | def diff_dataset_repr(a, b, compat): |
no test coverage detected
searching dependent graphs…