MCPcopy
hub / github.com/pydata/xarray / test_groupby_dataset_where

Function test_groupby_dataset_where

xarray/tests/test_groupby.py:1223–1238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1221
1222
1223def test_groupby_dataset_where() -> None:
1224 # groupby
1225 ds = Dataset({"a": ("x", range(5))}, {"c": ("x", [0, 0, 1, 1, 1])})
1226 cond = Dataset({"a": ("c", [True, False])})
1227 expected = ds.copy(deep=True)
1228 expected["a"].values = np.array([0, 1] + [np.nan] * 3)
1229 actual = ds.groupby("c").where(cond)
1230 assert_identical(expected, actual)
1231
1232 # attrs with groupby
1233 ds.attrs["attr"] = "ds"
1234 ds.a.attrs["attr"] = "da"
1235 actual = ds.groupby("c").where(cond)
1236 assert actual.attrs == ds.attrs
1237 assert actual.a.name == "a"
1238 assert actual.a.attrs == ds.a.attrs
1239
1240
1241def test_groupby_dataset_assign() -> None:

Callers

nothing calls this directly

Calls 5

copyMethod · 0.95
groupbyMethod · 0.95
DatasetClass · 0.90
assert_identicalFunction · 0.90
whereMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…