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

Function ensure_common_dims

xarray/structure/concat.py:719–730  ·  view source on GitHub ↗
(vars, concat_dim_lengths)

Source from the content-addressed store, hash-verified

717 # we've already verified everything is consistent; now, calculate
718 # shared dimension sizes so we can expand the necessary variables
719 def ensure_common_dims(vars, concat_dim_lengths):
720 # ensure each variable with the given name shares the same
721 # dimensions and the same shape for all of them except along the
722 # concat dimension
723 common_dims = tuple(utils.OrderedSet(d for v in vars for d in v.dims))
724 if dim_name not in common_dims:
725 common_dims = (dim_name,) + common_dims
726 for var, dim_len in zip(vars, concat_dim_lengths, strict=True):
727 if var.dims != common_dims:
728 common_shape = tuple(dims_sizes.get(d, dim_len) for d in common_dims)
729 var = var.set_dims(common_dims, common_shape)
730 yield var
731
732 # get the indexes to concatenate together, create a PandasIndex
733 # for any scalar coordinate variable found with ``name`` matching ``dim``.

Callers 1

_dataset_concatFunction · 0.85

Calls 2

set_dimsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…