MCPcopy Create free account
hub / github.com/pydata/xarray / test_groupby

Function test_groupby

xarray/tests/test_ufuncs.py:79–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77
78
79def 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
101def test_alignment():

Callers

nothing calls this directly

Calls 3

groupbyMethod · 0.95
assert_identicalFunction · 0.70
meanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…