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

Change chained replace inplace test to COW test for pandas 2.2 #15049

Merged
merged 2 commits into from
Feb 20, 2024
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
33 changes: 11 additions & 22 deletions python/cudf/cudf/tests/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,23 @@ def test_series_setitem_singleton_range():
assert_eq(sr, psr, check_dtype=True)


@pytest.mark.xfail(reason="Copy-on-Write should make a copy")
@pytest.mark.parametrize(
"df",
"index",
[
pd.DataFrame(
{"a": [1, 2, 3]},
index=pd.MultiIndex.from_frame(
pd.DataFrame({"b": [3, 2, 1], "c": ["a", "b", "c"]})
),
pd.MultiIndex.from_frame(
pd.DataFrame({"b": [3, 2, 1], "c": ["a", "b", "c"]})
),
pd.DataFrame({"a": [1, 2, 3]}, index=["a", "b", "c"]),
["a", "b", "c"],
],
)
def test_setitem_dataframe_series_inplace(df):
pdf = df.copy(deep=True)
gdf = cudf.from_pandas(pdf)

pdf["a"].replace(1, 500, inplace=True)
gdf["a"].replace(1, 500, inplace=True)

assert_eq(pdf, gdf)

psr_a = pdf["a"]
gsr_a = gdf["a"]

psr_a.replace(500, 501, inplace=True)
gsr_a.replace(500, 501, inplace=True)
def test_setitem_dataframe_series_inplace(index):
gdf = cudf.DataFrame({"a": [1, 2, 3]}, index=index)
expected = gdf.copy()
with cudf.option_context("copy_on_write", True):
gdf["a"].replace(1, 500, inplace=True)

assert_eq(pdf, gdf)
assert_eq(expected, gdf)


@pytest.mark.parametrize(
Expand Down
Loading