Skip to content

Commit b570356

Browse files
fix for default mode
1 parent 5a5a1d5 commit b570356

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/tests/copy_view/test_methods.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,7 @@ def test_xs(
16951695
using_copy_on_write, warn_copy_on_write, using_array_manager, axis, key, dtype
16961696
):
16971697
single_block = (dtype == "int64") and not using_array_manager
1698+
is_view = single_block or (using_array_manager and axis == 1)
16981699
df = DataFrame(
16991700
{"a": [1, 2, 3], "b": [4, 5, 6], "c": np.array([7, 8, 9], dtype=dtype)}
17001701
)
@@ -1707,7 +1708,7 @@ def test_xs(
17071708
elif using_copy_on_write:
17081709
assert result._mgr._has_no_reference(0)
17091710

1710-
if using_copy_on_write:
1711+
if using_copy_on_write or (is_view and not warn_copy_on_write):
17111712
result.iloc[0] = 0
17121713
elif warn_copy_on_write:
17131714
with tm.assert_cow_warning(single_block or axis == 1):

pandas/tests/indexing/test_chaining_and_caching.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def test_setitem_cache_updating_slices(
121121
out = DataFrame({"A": [0, 0, 0]}, index=date_range("5/7/2014", "5/9/2014"))
122122
for ix, row in df.iterrows():
123123
# TODO(CoW-warn) should not warn
124-
with tm.assert_produces_warning(FutureWarning):
124+
with tm.assert_produces_warning(
125+
FutureWarning if warn_copy_on_write else None
126+
):
125127
out.loc[six:eix, row["C"]] += row["D"]
126128

127129
tm.assert_frame_equal(out, expected)

0 commit comments

Comments
 (0)