Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated quantile test. #9945

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading