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
)
| 1955 | |
| 1956 | |
| 1957 | def 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 | |
| 1986 | def _wrap_index_equals( |
no test coverage detected
searching dependent graphs…