Skip to content
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
1 change: 1 addition & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12500,6 +12500,7 @@ def _inplace_method(self, other, op) -> Self:
and result._indexed_same(self)
and result.dtype == self.dtype
and not using_copy_on_write()
and not (warn_copy_on_write() and not warn)
):
# GH#36498 this inplace op can _actually_ be inplace.
# Item "ArrayManager" of "Union[ArrayManager, SingleArrayManager,
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def test_non_numeric_exclusion(self, interp_method, request, using_array_manager
request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set."))
tm.assert_series_equal(rs, xp)

# TODO(CoW-warn) should not need to warn
@pytest.mark.filterwarnings("ignore:Setting a value on a view:FutureWarning")
def test_axis(self, interp_method, request, using_array_manager):
# axis
interpolation, method = interp_method
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def test_repr():
assert result == expected


# TODO(CoW-warn) this should NOT warn -> inplace operator triggers it
@pytest.mark.filterwarnings("ignore:Setting a value on a view:FutureWarning")
def test_groupby_std_datetimelike(warn_copy_on_write):
# GH#48481
tdi = pd.timedelta_range("1 Day", periods=10000)
Expand Down
6 changes: 1 addition & 5 deletions pandas/tests/indexing/test_chaining_and_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ def test_setitem_cache_updating_slices(

out = DataFrame({"A": [0, 0, 0]}, index=date_range("5/7/2014", "5/9/2014"))
for ix, row in df.iterrows():
# TODO(CoW-warn) should not warn
with tm.assert_produces_warning(
FutureWarning if warn_copy_on_write else None
):
out.loc[six:eix, row["C"]] += row["D"]
out.loc[six:eix, row["C"]] += row["D"]

tm.assert_frame_equal(out, expected)
tm.assert_series_equal(out["A"], expected["A"])
Expand Down
10 changes: 3 additions & 7 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,7 @@ def test_iloc_getitem_slice_dups(self):
tm.assert_frame_equal(df.iloc[10:, :2], df2)
tm.assert_frame_equal(df.iloc[10:, 2:], df1)

# TODO(CoW-warn) this should NOT warn -> Series inplace operator
@pytest.mark.filterwarnings("ignore:Setting a value on a view:FutureWarning")
def test_iloc_setitem(self):
def test_iloc_setitem(self, warn_copy_on_write):
df = DataFrame(
np.random.default_rng(2).standard_normal((4, 4)),
index=np.arange(0, 8, 2),
Expand Down Expand Up @@ -1147,7 +1145,7 @@ def test_iloc_getitem_with_duplicates2(self):
expected = df.take([0], axis=1)
tm.assert_frame_equal(result, expected)

def test_iloc_interval(self, warn_copy_on_write):
def test_iloc_interval(self):
# GH#17130
df = DataFrame({Interval(1, 2): [1, 2]})

Expand All @@ -1160,9 +1158,7 @@ def test_iloc_interval(self, warn_copy_on_write):
tm.assert_series_equal(result, expected)

result = df.copy()
# TODO(CoW-warn) false positive
with tm.assert_cow_warning(warn_copy_on_write):
result.iloc[:, 0] += 1
result.iloc[:, 0] += 1
expected = DataFrame({Interval(1, 2): [2, 3]})
tm.assert_frame_equal(result, expected)

Expand Down