Skip to content

Commit

Permalink
Deprecate protocol and update tests accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Jan 14, 2025
1 parent 8470291 commit fa6e3ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import pandas as pd
import pyarrow as pa
from nvtx import annotate
from packaging import version
from pandas.io.formats import console
from pandas.io.formats.printing import pprint_thing
from typing_extensions import Self, assert_never
Expand Down Expand Up @@ -5562,6 +5563,12 @@ def from_pandas(cls, dataframe, nan_as_null=no_default):
elif hasattr(dataframe, "__dataframe__"):
# TODO: Probably should be handled in the constructor as
# this isn't pandas specific
assert version.parse(cudf.__version__) < version.parse("25.04.00")
warnings.warn(
"Support for loading dataframes via the `__dataframe__` interchange "
"protocol is deprecated",
FutureWarning,
)
return from_dataframe(dataframe, allow_copy=True)
else:
raise TypeError(
Expand Down Expand Up @@ -7709,6 +7716,8 @@ def pct_change(
def __dataframe__(
self, nan_as_null: bool = False, allow_copy: bool = True
):
assert version.parse(cudf.__version__) < version.parse("25.04.00")
warnings.warn("Using `__dataframe__` is deprecated", FutureWarning)
return df_protocol.__dataframe__(
self, nan_as_null=nan_as_null, allow_copy=allow_copy
)
Expand Down
6 changes: 5 additions & 1 deletion python/cudf/cudf/tests/test_df_protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
from __future__ import annotations

from typing import Any
Expand All @@ -22,6 +22,10 @@
)
from cudf.testing import assert_eq

pytestmark = pytest.mark.filterwarnings(
"ignore:Using `__dataframe__` is deprecated:FutureWarning"
)


@pytest.fixture(
params=[
Expand Down

0 comments on commit fa6e3ba

Please sign in to comment.