(
path: str,
node_ds: Dataset,
parent_ds: Dataset | None,
children: Mapping[str, DataTree],
)
| 165 | |
| 166 | |
| 167 | def 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 | |
| 196 | def _deduplicate_inherited_coordinates(child: DataTree, parent: DataTree) -> None: |
no test coverage detected
searching dependent graphs…