Skip to content

Commit 44c2d1e

Browse files
committed
Update
1 parent 819413f commit 44c2d1e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ def _get_values_tuple(self, key: tuple):
11711171
# If key is contained, would have returned by now
11721172
indexer, new_index = self.index.get_loc_level(key)
11731173
new_ser = self._constructor(self._values[indexer], index=new_index, copy=False)
1174-
if using_copy_on_write() and isinstance(indexer, slice):
1174+
if isinstance(indexer, slice):
11751175
new_ser._mgr.add_references(self._mgr) # type: ignore[arg-type]
11761176
return new_ser.__finalize__(self)
11771177

pandas/tests/copy_view/test_indexing.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1189,16 +1189,15 @@ def test_getitem_midx_slice(
11891189
assert df.iloc[0, 0] == 100
11901190

11911191

1192-
def test_series_midx_tuples_slice(using_copy_on_write):
1192+
def test_series_midx_tuples_slice(using_copy_on_write, warn_copy_on_write):
11931193
ser = Series(
11941194
[1, 2, 3],
11951195
index=pd.MultiIndex.from_tuples([((1, 2), 3), ((1, 2), 4), ((2, 3), 4)]),
11961196
)
11971197
result = ser[(1, 2)]
11981198
assert np.shares_memory(get_array(ser), get_array(result))
1199-
# TODO(CoW-warn) should warn -> reference is only tracked in CoW mode, so
1200-
# warning is not triggered
1201-
result.iloc[0] = 100
1199+
with tm.assert_cow_warning(warn_copy_on_write):
1200+
result.iloc[0] = 100
12021201
if using_copy_on_write:
12031202
expected = Series(
12041203
[1, 2, 3],

0 commit comments

Comments
 (0)