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

Function default_indexes

xarray/core/indexes.py:1957–1983  ·  view source on GitHub ↗

Default indexes for a Dataset/DataArray. Parameters ---------- coords : Mapping[Any, xarray.Variable] Coordinate variables from which to draw default indexes. dims : iterable Iterable of dimension names. Returns ------- Mapping from indexing keys (levels

(
    coords: Mapping[Any, Variable], dims: Iterable
)

Source from the content-addressed store, hash-verified

1955
1956
1957def default_indexes(
1958 coords: Mapping[Any, Variable], dims: Iterable
1959) -> dict[Hashable, Index]:
1960 """Default indexes for a Dataset/DataArray.
1961
1962 Parameters
1963 ----------
1964 coords : Mapping[Any, xarray.Variable]
1965 Coordinate variables from which to draw default indexes.
1966 dims : iterable
1967 Iterable of dimension names.
1968
1969 Returns
1970 -------
1971 Mapping from indexing keys (levels/dimension names) to indexes used for
1972 indexing along that dimension.
1973 """
1974 indexes: dict[Hashable, Index] = {}
1975 coord_names = set(coords)
1976
1977 for name, var in coords.items():
1978 if name in dims and var.ndim == 1:
1979 index, index_vars = create_default_index_implicit(var, coords)
1980 if set(index_vars) <= coord_names:
1981 indexes.update(dict.fromkeys(index_vars, index))
1982
1983 return indexes
1984
1985
1986def _wrap_index_equals(

Callers 1

Calls 3

itemsMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…