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

Function check_result_variables

xarray/core/parallel.py:43–65  ·  view source on GitHub ↗
(
    result: DataArray | Dataset,
    expected: ExpectedDict,
    kind: Literal["coords", "data_vars"],
)

Source from the content-addressed store, hash-verified

41
42
43def check_result_variables(
44 result: DataArray | Dataset,
45 expected: ExpectedDict,
46 kind: Literal["coords", "data_vars"],
47):
48 if kind == "coords":
49 nice_str = "coordinate"
50 elif kind == "data_vars":
51 nice_str = "data"
52
53 # check that coords and data variables are as expected
54 missing = expected[kind] - set(getattr(result, kind))
55 if missing:
56 raise ValueError(
57 "Result from applying user function does not contain "
58 f"{nice_str} variables {missing}."
59 )
60 extra = set(getattr(result, kind)) - expected[kind]
61 if extra:
62 raise ValueError(
63 "Result from applying user function has unexpected "
64 f"{nice_str} variables {extra}."
65 )
66
67
68def dataset_to_dataarray(obj: Dataset) -> DataArray:

Callers 1

_wrapperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…