| 343 | |
| 344 | @pytest.mark.parametrize("q", (-1, 1.1, (0.5, 1.1), ((0.2, 0.4), (0.6, 0.8)))) |
| 345 | def test_weighted_quantile_with_invalid_q(q): |
| 346 | da = DataArray([1, 1.9, 2.2, 3, 3.7, 4.1, 5]) |
| 347 | q = np.asarray(q) |
| 348 | weights = xr.ones_like(da) |
| 349 | |
| 350 | if q.ndim <= 1: |
| 351 | with pytest.raises(ValueError, match="q values must be between 0 and 1"): |
| 352 | da.weighted(weights).quantile(q) |
| 353 | else: |
| 354 | with pytest.raises(ValueError, match="q must be a scalar or 1d"): |
| 355 | da.weighted(weights).quantile(q) |
| 356 | |
| 357 | |
| 358 | @pytest.mark.parametrize( |