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

Function maybe_transpose_dims

xarray/testing/assertions.py:88–108  ·  view source on GitHub ↗

Helper for assert_equal/allclose/identical

(a, b, check_dim_order: bool)

Source from the content-addressed store, hash-verified

86
87
88def maybe_transpose_dims(a, b, check_dim_order: bool):
89 """Helper for assert_equal/allclose/identical"""
90
91 __tracebackhide__ = True
92
93 def _maybe_transpose_dims(a, b):
94 if not isinstance(a, Variable | DataArray | Dataset):
95 return b
96 if set(a.dims) == set(b.dims):
97 # Ensure transpose won't fail if a dimension is missing
98 # If this is the case, the difference will be caught by the caller
99 return b.transpose(*a.dims)
100 return b
101
102 if check_dim_order:
103 return b
104
105 if isinstance(a, DataTree):
106 return map_over_datasets(_maybe_transpose_dims, a, b)
107
108 return _maybe_transpose_dims(a, b)
109
110
111@ensure_warnings

Callers 2

assert_equalFunction · 0.85
assert_allcloseFunction · 0.85

Calls 2

map_over_datasetsFunction · 0.90
_maybe_transpose_dimsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…