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

Deprecate divisions='quantile' support in set_index #15804

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions python/dask_cudf/dask_cudf/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ def set_index(
pre_sorted = sorted
del sorted

if divisions == "quantile":
warnings.warn(
"Using divisions='quantile' is now deprecated. "
"Please raise an issue on github if you believe "
"this feature is necessary.",
FutureWarning,
)

if (
divisions == "quantile"
or isinstance(divisions, (cudf.DataFrame, cudf.Series))
Expand Down
18 changes: 18 additions & 0 deletions python/dask_cudf/dask_cudf/expr/_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ def from_dict(cls, *args, **kwargs):
with config.set({"dataframe.backend": "cudf"}):
return DXDataFrame.from_dict(*args, **kwargs)

def set_index(
self,
*args,
divisions=None,
**kwargs,
):
if divisions == "quantile":
divisions = None
warnings.warn(
"Ignoring divisions='quantile'. This option is now "
"deprecated. Please use the legacy API and raise an "
"issue on github if this feature is necessary."
f"\n{_LEGACY_WORKAROUND}",
FutureWarning,
)

return super().set_index(*args, divisions=divisions, **kwargs)

def groupby(
self,
by,
Expand Down
4 changes: 2 additions & 2 deletions python/dask_cudf/dask_cudf/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def test_set_index(nelem):
dd.assert_eq(expect, got, check_index=False, check_divisions=False)


@xfail_dask_expr("missing support for divisions='quantile'")
@pytest.mark.parametrize("by", ["a", "b"])
@pytest.mark.parametrize("nelem", [10, 500])
@pytest.mark.parametrize("nparts", [1, 10])
Expand All @@ -241,7 +240,8 @@ def test_set_index_quantile(nelem, nparts, by):
df["b"] = np.random.choice(cudf.datasets.names, size=nelem)
ddf = dd.from_pandas(df, npartitions=nparts)

got = ddf.set_index(by, divisions="quantile")
with pytest.warns(FutureWarning, match="deprecated"):
got = ddf.set_index(by, divisions="quantile")
expect = df.sort_values(by=by).set_index(by)
dd.assert_eq(got, expect)

Expand Down
Loading