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

Method test_groupby_math

xarray/tests/test_groupby.py:1556–1569  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1554 assert_identical(expected, actual)
1555
1556 def test_groupby_math(self) -> None:
1557 array = self.da
1558 grouped = array.groupby("abc")
1559 expected_agg = (grouped.mean(...) - np.arange(3)).rename(None)
1560 actual = grouped - DataArray(range(3), [("abc", ["a", "b", "c"])])
1561 actual_agg = actual.groupby("abc").mean(...)
1562 assert_allclose(expected_agg, actual_agg)
1563
1564 with pytest.raises(TypeError, match=r"only support binary ops"):
1565 grouped + 1 # type: ignore[type-var]
1566 with pytest.raises(TypeError, match=r"only support binary ops"):
1567 grouped + grouped # type: ignore[type-var]
1568 with pytest.raises(TypeError, match=r"in-place operations"):
1569 array += grouped # type: ignore[arg-type]
1570
1571 def test_groupby_math_not_aligned(self) -> None:
1572 array = DataArray(

Callers

nothing calls this directly

Calls 6

DataArrayClass · 0.90
assert_allcloseFunction · 0.90
arangeMethod · 0.80
groupbyMethod · 0.45
renameMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected