| 3248 | |
| 3249 | @requires_dask |
| 3250 | def test_lazy_grouping_errors() -> None: |
| 3251 | import dask.array |
| 3252 | |
| 3253 | data = DataArray( |
| 3254 | dims=("x",), |
| 3255 | data=dask.array.arange(20, chunks=3), |
| 3256 | name="foo", |
| 3257 | coords={"y": ("x", dask.array.arange(20, chunks=3))}, |
| 3258 | ) |
| 3259 | |
| 3260 | gb = data.groupby(y=UniqueGrouper(labels=np.arange(5, 10))) |
| 3261 | message = "not supported when lazily grouping by" |
| 3262 | with pytest.raises(ValueError, match=message): |
| 3263 | gb.map(lambda x: x) |
| 3264 | |
| 3265 | with pytest.raises(ValueError, match=message): |
| 3266 | gb.reduce(np.mean) |
| 3267 | |
| 3268 | with pytest.raises(ValueError, match=message): |
| 3269 | for _, _ in gb: |
| 3270 | pass |
| 3271 | |
| 3272 | |
| 3273 | @requires_dask |