diff --git a/xarray/core/coordinates.py b/xarray/core/coordinates.py index 251edd1fc6f..e85aafc4479 100644 --- a/xarray/core/coordinates.py +++ b/xarray/core/coordinates.py @@ -22,7 +22,11 @@ assert_no_index_corrupted, create_default_index_implicit, ) -from xarray.core.merge import merge_coordinates_without_align, merge_coords +from xarray.core.merge import ( + assert_valid_explicit_coords, + merge_coordinates_without_align, + merge_coords, +) from xarray.core.types import DataVars, Self, T_DataArray, T_Xarray from xarray.core.utils import ( Frozen, @@ -306,6 +310,14 @@ def __init__( else: variables[name] = var + dims = set(d for var in variables.values() for d in var.dims) + sizes = { + d: -1 for d in dims + } # TODO the lengths here are never used, so assert_valid_explicit_coords should be refactored + assert_valid_explicit_coords( + variables, dims=sizes, explicit_coords=list(variables) + ) + if indexes is None: indexes = {} else: