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

Function broadcast_dimension_size

xarray/structure/merge.py:85–96  ·  view source on GitHub ↗

Extract dimension sizes from a dictionary of variables. Raises ValueError if any dimensions have different sizes.

(variables: list[Variable])

Source from the content-addressed store, hash-verified

83
84
85def broadcast_dimension_size(variables: list[Variable]) -> dict[Hashable, int]:
86 """Extract dimension sizes from a dictionary of variables.
87
88 Raises ValueError if any dimensions have different sizes.
89 """
90 dims: dict[Hashable, int] = {}
91 for var in variables:
92 for dim, size in zip(var.dims, var.shape, strict=True):
93 if dim in dims and size != dims[dim]:
94 raise ValueError(f"index {dim!r} not aligned")
95 dims[dim] = size
96 return dims
97
98
99class MergeError(ValueError):

Callers 1

unique_variableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…