Skip to content

Commit 2c8b6e6

Browse files
dcherianheadtr1ck
andauthored
Remove outdated quantile test. (#9945)
* Remove outdated quantile test. dask now auto-rechunks for quantile. Closes #9860 * Apply suggestions from code review Co-authored-by: Michael Niklas <[email protected]> --------- Co-authored-by: Michael Niklas <[email protected]>
1 parent 5279bd1 commit 2c8b6e6

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Diff for: xarray/tests/test_groupby.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,13 @@ def test_da_groupby_empty() -> None:
284284

285285
@requires_dask
286286
def test_dask_da_groupby_quantile() -> None:
287-
# Only works when the grouped reduction can run blockwise
288287
# Scalar quantile
289288
expected = xr.DataArray(
290289
data=[2, 5], coords={"x": [1, 2], "quantile": 0.5}, dims="x"
291290
)
292291
array = xr.DataArray(
293292
data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
294293
)
295-
with pytest.raises(ValueError):
296-
array.chunk(x=1).groupby("x").quantile(0.5)
297294

298295
# will work blockwise with flox
299296
actual = array.chunk(x=3).groupby("x").quantile(0.5)
@@ -327,7 +324,8 @@ def test_dask_da_groupby_median() -> None:
327324
assert_identical(expected, actual)
328325

329326

330-
def test_da_groupby_quantile() -> None:
327+
@pytest.mark.parametrize("use_flox", [pytest.param(True, marks=requires_flox), False])
328+
def test_da_groupby_quantile(use_flox: bool) -> None:
331329
array = xr.DataArray(
332330
data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
333331
)
@@ -336,16 +334,19 @@ def test_da_groupby_quantile() -> None:
336334
expected = xr.DataArray(
337335
data=[2, 5], coords={"x": [1, 2], "quantile": 0.5}, dims="x"
338336
)
339-
actual = array.groupby("x").quantile(0.5)
340-
assert_identical(expected, actual)
337+
338+
with xr.set_options(use_flox=use_flox):
339+
actual = array.groupby("x").quantile(0.5)
340+
assert_identical(expected, actual)
341341

342342
# Vector quantile
343343
expected = xr.DataArray(
344344
data=[[1, 3], [4, 6]],
345345
coords={"x": [1, 2], "quantile": [0, 1]},
346346
dims=("x", "quantile"),
347347
)
348-
actual = array.groupby("x").quantile([0, 1])
348+
with xr.set_options(use_flox=use_flox):
349+
actual = array.groupby("x").quantile([0, 1])
349350
assert_identical(expected, actual)
350351

351352
array = xr.DataArray(
@@ -356,7 +357,8 @@ def test_da_groupby_quantile() -> None:
356357
e = [np.nan, 5] if skipna is False else [2.5, 5]
357358

358359
expected = xr.DataArray(data=e, coords={"x": [1, 2], "quantile": 0.5}, dims="x")
359-
actual = array.groupby("x").quantile(0.5, skipna=skipna)
360+
with xr.set_options(use_flox=use_flox):
361+
actual = array.groupby("x").quantile(0.5, skipna=skipna)
360362
assert_identical(expected, actual)
361363

362364
# Multiple dimensions

0 commit comments

Comments
 (0)