(method, quantile)
| 1359 | ) |
| 1360 | @pytest.mark.parametrize("quantile", (0.3, 0.5, 0.9)) |
| 1361 | def 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( |
nothing calls this directly
no test coverage detected
searching dependent graphs…