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

CoW: Update test with read-only array #56418

Merged
merged 1 commit into from
Dec 11, 2023
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
10 changes: 3 additions & 7 deletions pandas/tests/frame/methods/test_to_dict_of_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def test_no_copy_blocks(self, float_frame, using_copy_on_write):
assert _last_df is not None and not _last_df[column].equals(df[column])


def test_to_dict_of_blocks_item_cache(request, using_copy_on_write, warn_copy_on_write):
if using_copy_on_write:
request.applymarker(pytest.mark.xfail(reason="CoW - not yet implemented"))
def test_to_dict_of_blocks_item_cache(using_copy_on_write, warn_copy_on_write):
# Calling to_dict_of_blocks should not poison item_cache
df = DataFrame({"a": [1, 2, 3, 4], "b": ["a", "b", "c", "d"]})
df["c"] = NumpyExtensionArray(np.array([1, 2, None, 3], dtype=object))
Expand All @@ -65,10 +63,8 @@ def test_to_dict_of_blocks_item_cache(request, using_copy_on_write, warn_copy_on
df._to_dict_of_blocks()

if using_copy_on_write:
# TODO(CoW) we should disallow this, so `df` doesn't get updated,
# this currently still updates df, so this test fails
ser.values[0] = "foo"
assert df.loc[0, "b"] == "a"
with pytest.raises(ValueError, match="read-only"):
ser.values[0] = "foo"
elif warn_copy_on_write:
ser.values[0] = "foo"
assert df.loc[0, "b"] == "foo"
Expand Down
Loading