MCPcopy
hub / github.com/pydata/xarray / _calc_concat_dim_index

Function _calc_concat_dim_index

xarray/structure/concat.py:344–368  ·  view source on GitHub ↗

Infer the dimension name and 1d index / coordinate variable (if appropriate) for concatenating along the new dimension.

(
    dim_or_data: Hashable | Any,
)

Source from the content-addressed store, hash-verified

342
343
344def _calc_concat_dim_index(
345 dim_or_data: Hashable | Any,
346) -> tuple[Hashable, PandasIndex | None]:
347 """Infer the dimension name and 1d index / coordinate variable (if appropriate)
348 for concatenating along the new dimension.
349
350 """
351 from xarray.core.dataarray import DataArray
352
353 dim: Hashable | None
354
355 if utils.hashable(dim_or_data):
356 dim = dim_or_data
357 index = None
358 else:
359 if not isinstance(dim_or_data, DataArray | Variable):
360 dim = getattr(dim_or_data, "name", None)
361 if dim is None:
362 dim = "concat_dim"
363 else:
364 (dim,) = dim_or_data.dims
365 coord_dtype = getattr(dim_or_data, "dtype", None)
366 index = PandasIndex(dim_or_data, dim, coord_dtype=coord_dtype)
367
368 return dim, index
369
370
371def _calc_concat_over(

Callers 2

_dataset_concatFunction · 0.85
_datatree_concatFunction · 0.85

Calls 1

PandasIndexClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…