(self)
| 1787 | assert_identical(actual, expected) |
| 1788 | |
| 1789 | def test_groupby_bins_empty(self) -> None: |
| 1790 | array = DataArray(np.arange(4), [("x", range(4))]) |
| 1791 | # one of these bins will be empty |
| 1792 | bins = [0, 4, 5] |
| 1793 | bin_coords = pd.cut(array["x"], bins).categories # type: ignore[call-overload] |
| 1794 | actual = array.groupby_bins("x", bins).sum() |
| 1795 | expected = DataArray([6, np.nan], dims="x_bins", coords={"x_bins": bin_coords}) |
| 1796 | assert_identical(expected, actual) |
| 1797 | # make sure original array is unchanged |
| 1798 | # (was a problem in earlier versions) |
| 1799 | assert len(array.x) == 4 |
| 1800 | |
| 1801 | def test_groupby_bins_multidim(self) -> None: |
| 1802 | array = self.make_groupby_multidim_example_array() |
nothing calls this directly
no test coverage detected