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

Function _check_dim_compat

xarray/core/indexes.py:968–988  ·  view source on GitHub ↗

Check that all multi-index variable candidates are 1-dimensional and either share the same (single) dimension or each have a different dimension.

(variables: Mapping[Any, Variable], all_dims: str = "equal")

Source from the content-addressed store, hash-verified

966
967
968def _check_dim_compat(variables: Mapping[Any, Variable], all_dims: str = "equal"):
969 """Check that all multi-index variable candidates are 1-dimensional and
970 either share the same (single) dimension or each have a different dimension.
971
972 """
973 if any(var.ndim != 1 for var in variables.values()):
974 raise ValueError("PandasMultiIndex only accepts 1-dimensional variables")
975
976 dims = {var.dims for var in variables.values()}
977
978 if all_dims == "equal" and len(dims) > 1:
979 raise ValueError(
980 "unmatched dimensions for multi-index variables "
981 + ", ".join([f"{k!r} {v.dims}" for k, v in variables.items()])
982 )
983
984 if all_dims == "different" and len(dims) < len(variables):
985 raise ValueError(
986 "conflicting dimensions for multi-index product variables "
987 + ", ".join([f"{k!r} {v.dims}" for k, v in variables.items()])
988 )
989
990
991T_PDIndex = TypeVar("T_PDIndex", bound=pd.Index)

Callers 3

from_variablesMethod · 0.85
stackMethod · 0.85

Calls 3

itemsMethod · 0.80
valuesMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…