MCPcopy Index your code
hub / github.com/dask/dask / test_quantile

Function test_quantile

dask/dataframe/tests/test_dataframe.py:1361–1380  ·  view source on GitHub ↗
(method, quantile)

Source from the content-addressed store, hash-verified

1359)
1360@pytest.mark.parametrize("quantile", (0.3, 0.5, 0.9))
1361def test_quantile(method, quantile):
1362 # https://en.wikipedia.org/wiki/Exponential_distribution
1363 array = da.random.exponential(1, 10_000, chunks=(10_000 // 2))
1364 df = dd.from_dask_array(array, columns=["x"])
1365 exp = -np.log(1 - quantile) * 1
1366
1367 # dataframe
1368 result = df.x.quantile([quantile], method=method)
1369 assert len(result) == 1
1370 assert result.divisions == (quantile, quantile)
1371 assert isinstance(result, dd.Series)
1372 result = result.compute()
1373 assert isinstance(result, pd.Series)
1374 assert result.iloc[0] == pytest.approx(exp, rel=0.15)
1375
1376 # series / single
1377 result = df.x.quantile(quantile, method=method)
1378 assert result.ndim == 0
1379 result = result.compute()
1380 assert result == pytest.approx(exp, rel=0.15)
1381
1382
1383@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

exponentialMethod · 0.45
quantileMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…