()
| 77 | |
| 78 | |
| 79 | def test_groupby(): |
| 80 | ds = xr.Dataset({"a": ("x", [0, 0, 0])}, {"c": ("x", [0, 0, 1])}) |
| 81 | ds_grouped = ds.groupby("c") |
| 82 | group_mean = ds_grouped.mean("x") |
| 83 | arr_grouped = ds["a"].groupby("c") |
| 84 | |
| 85 | assert_identical(ds, np.maximum(ds_grouped, group_mean)) # type: ignore[call-overload] |
| 86 | assert_identical(ds, np.maximum(group_mean, ds_grouped)) # type: ignore[call-overload] |
| 87 | |
| 88 | assert_identical(ds, np.maximum(arr_grouped, group_mean)) # type: ignore[call-overload] |
| 89 | assert_identical(ds, np.maximum(group_mean, arr_grouped)) # type: ignore[call-overload] |
| 90 | |
| 91 | assert_identical(ds, np.maximum(ds_grouped, group_mean["a"])) # type: ignore[call-overload] |
| 92 | assert_identical(ds, np.maximum(group_mean["a"], ds_grouped)) # type: ignore[call-overload] |
| 93 | |
| 94 | assert_identical(ds.a, np.maximum(arr_grouped, group_mean.a)) # type: ignore[call-overload] |
| 95 | assert_identical(ds.a, np.maximum(group_mean.a, arr_grouped)) # type: ignore[call-overload] |
| 96 | |
| 97 | with pytest.raises(ValueError, match=r"mismatched lengths for dimension"): |
| 98 | np.maximum(ds.a.variable, ds_grouped) # type: ignore[call-overload] |
| 99 | |
| 100 | |
| 101 | def test_alignment(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…