@@ -324,7 +324,7 @@ def test_frame_setitem_existing_datetime64_col_other_units(self, unit):
324
324
df ["dates" ] = vals
325
325
assert (df ["dates" ].values == ex_vals ).all ()
326
326
327
- def test_setitem_dt64tz (self , timezone_frame , using_copy_on_write ):
327
+ def test_setitem_dt64tz (self , timezone_frame ):
328
328
df = timezone_frame
329
329
idx = df ["B" ].rename ("foo" )
330
330
@@ -345,10 +345,7 @@ def test_setitem_dt64tz(self, timezone_frame, using_copy_on_write):
345
345
tm .assert_extension_array_equal (v1 , v2 )
346
346
v1base = v1 ._ndarray .base
347
347
v2base = v2 ._ndarray .base
348
- if not using_copy_on_write :
349
- assert v1base is None or (id (v1base ) != id (v2base ))
350
- else :
351
- assert id (v1base ) == id (v2base )
348
+ assert id (v1base ) == id (v2base )
352
349
353
350
# with nan
354
351
df2 = df .copy ()
@@ -844,7 +841,7 @@ def test_setitem_object_array_of_tzaware_datetimes(self, idx, expected):
844
841
845
842
846
843
class TestDataFrameSetItemWithExpansion :
847
- def test_setitem_listlike_views (self , using_copy_on_write ):
844
+ def test_setitem_listlike_views (self ):
848
845
# GH#38148
849
846
df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 4 , 6 ]})
850
847
@@ -857,10 +854,7 @@ def test_setitem_listlike_views(self, using_copy_on_write):
857
854
# edit in place the first column to check view semantics
858
855
df .iloc [0 , 0 ] = 100
859
856
860
- if using_copy_on_write :
861
- expected = Series ([1 , 2 , 3 ], name = "a" )
862
- else :
863
- expected = Series ([100 , 2 , 3 ], name = "a" )
857
+ expected = Series ([1 , 2 , 3 ], name = "a" )
864
858
tm .assert_series_equal (ser , expected )
865
859
866
860
def test_setitem_string_column_numpy_dtype_raising (self ):
@@ -870,7 +864,7 @@ def test_setitem_string_column_numpy_dtype_raising(self):
870
864
expected = DataFrame ([[1 , 2 , 5 ], [3 , 4 , 6 ]], columns = [0 , 1 , "0 - Name" ])
871
865
tm .assert_frame_equal (df , expected )
872
866
873
- def test_setitem_empty_df_duplicate_columns (self , using_copy_on_write ):
867
+ def test_setitem_empty_df_duplicate_columns (self ):
874
868
# GH#38521
875
869
df = DataFrame (columns = ["a" , "b" , "b" ], dtype = "float64" )
876
870
df .loc [:, "a" ] = list (range (2 ))
@@ -1199,7 +1193,7 @@ def test_setitem_always_copy(self, float_frame):
1199
1193
assert notna (s [5 :10 ]).all ()
1200
1194
1201
1195
@pytest .mark .parametrize ("consolidate" , [True , False ])
1202
- def test_setitem_partial_column_inplace (self , consolidate , using_copy_on_write ):
1196
+ def test_setitem_partial_column_inplace (self , consolidate ):
1203
1197
# This setting should be in-place, regardless of whether frame is
1204
1198
# single-block or multi-block
1205
1199
# GH#304 this used to be incorrectly not-inplace, in which case
@@ -1215,18 +1209,11 @@ def test_setitem_partial_column_inplace(self, consolidate, using_copy_on_write):
1215
1209
else :
1216
1210
assert len (df ._mgr .blocks ) == 2
1217
1211
1218
- zvals = df ["z" ]._values
1219
-
1220
1212
df .loc [2 :, "z" ] = 42
1221
1213
1222
1214
expected = Series ([np .nan , np .nan , 42 , 42 ], index = df .index , name = "z" )
1223
1215
tm .assert_series_equal (df ["z" ], expected )
1224
1216
1225
- # check setting occurred in-place
1226
- if not using_copy_on_write :
1227
- tm .assert_numpy_array_equal (zvals , expected .values )
1228
- assert np .shares_memory (zvals , df ["z" ]._values )
1229
-
1230
1217
def test_setitem_duplicate_columns_not_inplace (self ):
1231
1218
# GH#39510
1232
1219
cols = ["A" , "B" ] * 2
@@ -1298,7 +1285,7 @@ def test_setitem_not_operating_inplace(self, value, set_value, indexer):
1298
1285
df [indexer ] = set_value
1299
1286
tm .assert_frame_equal (view , expected )
1300
1287
1301
- def test_setitem_column_update_inplace (self , using_copy_on_write ):
1288
+ def test_setitem_column_update_inplace (self ):
1302
1289
# https://github.com/pandas-dev/pandas/issues/47172
1303
1290
1304
1291
labels = [f"c{ i } " for i in range (10 )]
@@ -1308,12 +1295,8 @@ def test_setitem_column_update_inplace(self, using_copy_on_write):
1308
1295
with tm .raises_chained_assignment_error ():
1309
1296
for label in df .columns :
1310
1297
df [label ][label ] = 1
1311
- if not using_copy_on_write :
1312
- # diagonal values all updated
1313
- assert np .all (values [np .arange (10 ), np .arange (10 )] == 1 )
1314
- else :
1315
- # original dataframe not updated
1316
- assert np .all (values [np .arange (10 ), np .arange (10 )] == 0 )
1298
+ # original dataframe not updated
1299
+ assert np .all (values [np .arange (10 ), np .arange (10 )] == 0 )
1317
1300
1318
1301
def test_setitem_column_frame_as_category (self ):
1319
1302
# GH31581
0 commit comments