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

Function test_groupby_getitem

xarray/tests/test_groupby.py:827–841  ·  view source on GitHub ↗
(dataset)

Source from the content-addressed store, hash-verified

825
826
827def test_groupby_getitem(dataset) -> None:
828 assert_identical(dataset.sel(x=["a"]), dataset.groupby("x")["a"])
829 assert_identical(dataset.sel(z=[1]), dataset.groupby("z")[1])
830 assert_identical(dataset.foo.sel(x=["a"]), dataset.foo.groupby("x")["a"])
831 assert_identical(dataset.foo.sel(z=[1]), dataset.foo.groupby("z")[1])
832 assert_identical(dataset.cat.sel(y=[1]), dataset.cat.groupby("y")[1])
833
834 with pytest.raises(
835 NotImplementedError, match=r"Cannot broadcast 1d-only pandas extension array."
836 ):
837 dataset.groupby("boo")
838 dataset = dataset.drop_vars(["cat"])
839 actual = dataset.groupby("boo")["f"].unstack().transpose("x", "y", "z")
840 expected = dataset.sel(y=[1], z=[1, 2]).transpose("x", "y", "z")
841 assert_identical(expected, actual)
842
843
844def test_groupby_dataset() -> None:

Callers

nothing calls this directly

Calls 6

assert_identicalFunction · 0.90
selMethod · 0.45
groupbyMethod · 0.45
drop_varsMethod · 0.45
transposeMethod · 0.45
unstackMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…