(weights, expected)
| 209 | ), |
| 210 | ) |
| 211 | def test_weighted_quantile_no_nan(weights, expected): |
| 212 | # Expected values were calculated by running the reference implementation |
| 213 | # proposed in https://aakinshin.net/posts/weighted-quantiles/ |
| 214 | |
| 215 | da = DataArray([1, 1.9, 2.2, 3, 3.7, 4.1, 5]) |
| 216 | q = [0.2, 0.4, 0.6, 0.8] |
| 217 | weights = DataArray(weights) |
| 218 | |
| 219 | expected = DataArray(expected, coords={"quantile": q}) |
| 220 | result = da.weighted(weights).quantile(q) |
| 221 | |
| 222 | assert_allclose(expected, result) |
| 223 | |
| 224 | |
| 225 | def test_weighted_quantile_zero_weights(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…