Skip to content

Commit

Permalink
Remove outdated quantile test. (pydata#9945)
Browse files Browse the repository at this point in the history
* Remove outdated quantile test.

dask now auto-rechunks for quantile.

Closes pydata#9860

* Apply suggestions from code review

Co-authored-by: Michael Niklas  <[email protected]>

---------

Co-authored-by: Michael Niklas <[email protected]>
  • Loading branch information
dcherian and headtr1ck authored Jan 14, 2025
1 parent 5279bd1 commit 2c8b6e6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,13 @@ def test_da_groupby_empty() -> None:

@requires_dask
def test_dask_da_groupby_quantile() -> None:
# Only works when the grouped reduction can run blockwise
# Scalar quantile
expected = xr.DataArray(
data=[2, 5], coords={"x": [1, 2], "quantile": 0.5}, dims="x"
)
array = xr.DataArray(
data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
)
with pytest.raises(ValueError):
array.chunk(x=1).groupby("x").quantile(0.5)

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


def test_da_groupby_quantile() -> None:
@pytest.mark.parametrize("use_flox", [pytest.param(True, marks=requires_flox), False])
def test_da_groupby_quantile(use_flox: bool) -> None:
array = xr.DataArray(
data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
)
Expand All @@ -336,16 +334,19 @@ def test_da_groupby_quantile() -> None:
expected = xr.DataArray(
data=[2, 5], coords={"x": [1, 2], "quantile": 0.5}, dims="x"
)
actual = array.groupby("x").quantile(0.5)
assert_identical(expected, actual)

with xr.set_options(use_flox=use_flox):
actual = array.groupby("x").quantile(0.5)
assert_identical(expected, actual)

# Vector quantile
expected = xr.DataArray(
data=[[1, 3], [4, 6]],
coords={"x": [1, 2], "quantile": [0, 1]},
dims=("x", "quantile"),
)
actual = array.groupby("x").quantile([0, 1])
with xr.set_options(use_flox=use_flox):
actual = array.groupby("x").quantile([0, 1])
assert_identical(expected, actual)

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

expected = xr.DataArray(data=e, coords={"x": [1, 2], "quantile": 0.5}, dims="x")
actual = array.groupby("x").quantile(0.5, skipna=skipna)
with xr.set_options(use_flox=use_flox):
actual = array.groupby("x").quantile(0.5, skipna=skipna)
assert_identical(expected, actual)

# Multiple dimensions
Expand Down

0 comments on commit 2c8b6e6

Please sign in to comment.