Skip to content

CoW: Remove todos that aren't necessary #56169

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

Merged
merged 7 commits into from
Nov 27, 2023
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
5 changes: 3 additions & 2 deletions pandas/tests/apply/test_invalid_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_transform_axis_1_raises():

# TODO(CoW-warn) should not need to warn
@pytest.mark.filterwarnings("ignore:Setting a value on a view:FutureWarning")
def test_apply_modify_traceback():
def test_apply_modify_traceback(warn_copy_on_write):
data = DataFrame(
{
"A": [
Expand Down Expand Up @@ -214,7 +214,8 @@ def transform2(row):

msg = "'float' object has no attribute 'startswith'"
with pytest.raises(AttributeError, match=msg):
data.apply(transform, axis=1)
with tm.assert_cow_warning(warn_copy_on_write):
data.apply(transform, axis=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason I thought this didn't need to warn is that row should not be a view, given the dataframe has mixed dtypes.
So after CoW is enabled, nothing will change here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sorry, you are correct

The implementation is dirty... I'll mess around with it later today



@pytest.mark.parametrize(
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/copy_view/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def test_dataframe_from_series_or_index(
if using_copy_on_write:
assert not df._mgr._has_no_reference(0)

# TODO(CoW-warn) should not warn for an index?
with tm.assert_cow_warning(warn_copy_on_write):
df.iloc[0, 0] = data[-1]
if using_copy_on_write:
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/copy_view/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ def test_del_frame(backend, using_copy_on_write, warn_copy_on_write):
tm.assert_frame_equal(df2, df_orig[["a", "c"]])
df2._mgr._verify_integrity()

# TODO(CoW-warn) false positive, this should not warn?
with tm.assert_cow_warning(warn_copy_on_write and dtype_backend == "numpy"):
df.loc[0, "b"] = 200
assert np.shares_memory(get_array(df, "a"), get_array(df2, "a"))
Expand Down