| 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( |