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

Function check_alignment

xarray/core/datatree.py:167–193  ·  view source on GitHub ↗
(
    path: str,
    node_ds: Dataset,
    parent_ds: Dataset | None,
    children: Mapping[str, DataTree],
)

Source from the content-addressed store, hash-verified

165
166
167def check_alignment(
168 path: str,
169 node_ds: Dataset,
170 parent_ds: Dataset | None,
171 children: Mapping[str, DataTree],
172) -> None:
173 if parent_ds is not None:
174 try:
175 align(node_ds, parent_ds, join="exact", copy=False)
176 except ValueError as e:
177 node_repr = _indented(_without_header(repr(node_ds)))
178 parent_repr = _indented(dims_and_coords_repr(parent_ds))
179 raise ValueError(
180 f"group {path!r} is not aligned with its parents:\n"
181 f"Group:\n{node_repr}\nFrom parents:\n{parent_repr}"
182 ) from e
183
184 if children:
185 if parent_ds is not None:
186 base_ds = _inherited_dataset(node_ds, parent_ds)
187 else:
188 base_ds = node_ds
189
190 for child_name, child in children.items():
191 child_path = str(NodePath(path) / child_name)
192 child_ds = child.to_dataset(inherit=False)
193 check_alignment(child_path, child_ds, base_ds, child.children)
194
195
196def _deduplicate_inherited_coordinates(child: DataTree, parent: DataTree) -> None:

Callers 3

_update_coordsMethod · 0.90
_pre_attachMethod · 0.85
_replace_nodeMethod · 0.85

Calls 8

alignFunction · 0.90
dims_and_coords_reprFunction · 0.90
NodePathClass · 0.90
_indentedFunction · 0.85
_without_headerFunction · 0.85
_inherited_datasetFunction · 0.85
itemsMethod · 0.80
to_datasetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…