(
result: DataArray | Dataset,
expected: ExpectedDict,
kind: Literal["coords", "data_vars"],
)
| 41 | |
| 42 | |
| 43 | def 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 | |
| 68 | def dataset_to_dataarray(obj: Dataset) -> DataArray: |
no outgoing calls
no test coverage detected
searching dependent graphs…