()
| 234 | |
| 235 | |
| 236 | def test_weighted_quantile_simple(): |
| 237 | # Check that weighted quantiles return the same value as numpy quantiles |
| 238 | da = DataArray([0, 1, 2, 3]) |
| 239 | w = DataArray([1, 0, 1, 0]) |
| 240 | |
| 241 | w_eps = DataArray([1, 0.0001, 1, 0.0001]) |
| 242 | q = 0.75 |
| 243 | |
| 244 | expected = DataArray(np.quantile([0, 2], q), coords={"quantile": q}) # 1.5 |
| 245 | |
| 246 | assert_equal(expected, da.weighted(w).quantile(q)) |
| 247 | assert_allclose(expected, da.weighted(w_eps).quantile(q), rtol=0.001) |
| 248 | |
| 249 | |
| 250 | @pytest.mark.parametrize("skipna", (True, False)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…