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

Function determine_coords

xarray/structure/merge.py:473–508  ·  view source on GitHub ↗

Given a list of dicts with xarray object values, identify coordinates. Parameters ---------- list_of_mappings : list of dict or list of Dataset Of the same form as the arguments to expand_variable_dicts. Returns ------- coord_names : set of variable names noncoo

(
    list_of_mappings: Iterable[DatasetLike],
)

Source from the content-addressed store, hash-verified

471
472
473def determine_coords(
474 list_of_mappings: Iterable[DatasetLike],
475) -> tuple[set[Hashable], set[Hashable]]:
476 """Given a list of dicts with xarray object values, identify coordinates.
477
478 Parameters
479 ----------
480 list_of_mappings : list of dict or list of Dataset
481 Of the same form as the arguments to expand_variable_dicts.
482
483 Returns
484 -------
485 coord_names : set of variable names
486 noncoord_names : set of variable names
487 All variable found in the input should appear in either the set of
488 coordinate or non-coordinate names.
489 """
490 from xarray.core.dataarray import DataArray
491 from xarray.core.dataset import Dataset
492
493 coord_names: set[Hashable] = set()
494 noncoord_names: set[Hashable] = set()
495
496 for mapping in list_of_mappings:
497 if isinstance(mapping, Dataset):
498 coord_names.update(mapping.coords)
499 noncoord_names.update(mapping.data_vars)
500 else:
501 for name, var in mapping.items():
502 if isinstance(var, DataArray):
503 coords = set(var._coords) # use private API for speed
504 # explicitly overwritten variables should take precedence
505 coords.discard(name)
506 coord_names.update(coords)
507
508 return coord_names, noncoord_names
509
510
511def coerce_pandas_values(objects: Iterable[CoercibleMapping]) -> list[DatasetLike]:

Callers 1

merge_coreFunction · 0.85

Calls 3

itemsMethod · 0.80
discardMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…