Infer the dimension name and 1d index / coordinate variable (if appropriate) for concatenating along the new dimension.
(
dim_or_data: Hashable | Any,
)
| 342 | |
| 343 | |
| 344 | def _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 | |
| 371 | def _calc_concat_over( |
no test coverage detected
searching dependent graphs…