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

Function test_weighted_quantile_no_nan

xarray/tests/test_weighted.py:211–222  ·  view source on GitHub ↗
(weights, expected)

Source from the content-addressed store, hash-verified

209 ),
210)
211def 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
225def test_weighted_quantile_zero_weights():

Callers

nothing calls this directly

Calls 4

weightedMethod · 0.95
DataArrayClass · 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…