(operation, as_dataset)
| 789 | @pytest.mark.parametrize("operation", ("sum_of_weights", "sum", "mean", "quantile")) |
| 790 | @pytest.mark.parametrize("as_dataset", (True, False)) |
| 791 | def test_weighted_bad_dim(operation, as_dataset): |
| 792 | data_array = DataArray(np.random.randn(2, 2)) |
| 793 | weights = xr.ones_like(data_array) |
| 794 | data: DataArray | Dataset = data_array |
| 795 | if as_dataset: |
| 796 | data = data_array.to_dataset(name="data") |
| 797 | |
| 798 | kwargs: dict[str, Any] = {"dim": "bad_dim"} |
| 799 | if operation == "quantile": |
| 800 | kwargs["q"] = 0.5 |
| 801 | |
| 802 | with pytest.raises( |
| 803 | ValueError, |
| 804 | match=( |
| 805 | f"Dimensions \\('bad_dim',\\) not found in {data.__class__.__name__}Weighted " |
| 806 | # the order of (dim_0, dim_1) varies |
| 807 | "dimensions \\(('dim_0', 'dim_1'|'dim_1', 'dim_0')\\)" |
| 808 | ), |
| 809 | ): |
| 810 | getattr(data.weighted(weights), operation)(**kwargs) |
nothing calls this directly
no test coverage detected
searching dependent graphs…