MCPcopy
hub / github.com/pydata/xarray / test_weighted_quantile_simple

Function test_weighted_quantile_simple

xarray/tests/test_weighted.py:236–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

234
235
236def 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))

Callers

nothing calls this directly

Calls 5

weightedMethod · 0.95
DataArrayClass · 0.90
assert_equalFunction · 0.90
assert_allcloseFunction · 0.90
quantileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…