MCPcopy
hub / github.com/pydata/xarray / assert_isomorphic

Function assert_isomorphic

xarray/testing/assertions.py:56–85  ·  view source on GitHub ↗

Two DataTrees are considered isomorphic if the set of paths to their descendent nodes are the same. Nothing about the data or attrs in each node is checked. Isomorphism is a necessary condition for two trees to be used in a nodewise binary operation, such as tree1 + tree2.

(a: DataTree, b: DataTree)

Source from the content-addressed store, hash-verified

54
55@ensure_warnings
56def assert_isomorphic(a: DataTree, b: DataTree):
57 """
58 Two DataTrees are considered isomorphic if the set of paths to their
59 descendent nodes are the same.
60
61 Nothing about the data or attrs in each node is checked.
62
63 Isomorphism is a necessary condition for two trees to be used in a nodewise binary operation,
64 such as tree1 + tree2.
65
66 Parameters
67 ----------
68 a : DataTree
69 The first object to compare.
70 b : DataTree
71 The second object to compare.
72
73 See Also
74 --------
75 DataTree.isomorphic
76 assert_equal
77 assert_identical
78 """
79 __tracebackhide__ = True
80 assert isinstance(a, type(b))
81
82 if isinstance(a, DataTree):
83 assert a.isomorphic(b), diff_datatree_repr(a, b, "isomorphic")
84 else:
85 raise TypeError(f"{type(a)} not of type DataTree")
86
87
88def maybe_transpose_dims(a, b, check_dim_order: bool):

Callers

nothing calls this directly

Calls 3

diff_datatree_reprFunction · 0.90
typeFunction · 0.85
isomorphicMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…