@@ -140,15 +140,11 @@ def test_subset_row_slice(backend, using_copy_on_write, warn_copy_on_write):
140
140
@pytest .mark .parametrize (
141
141
"dtype" , ["int64" , "float64" ], ids = ["single-block" , "mixed-block" ]
142
142
)
143
- def test_subset_column_slice (
144
- backend , using_copy_on_write , warn_copy_on_write , using_array_manager , dtype
145
- ):
143
+ def test_subset_column_slice (backend , using_copy_on_write , warn_copy_on_write , dtype ):
146
144
# Case: taking a subset of the columns of a DataFrame using a slice
147
145
# + afterwards modifying the subset
148
146
dtype_backend , DataFrame , _ = backend
149
- single_block = (
150
- dtype == "int64" and dtype_backend == "numpy"
151
- ) and not using_array_manager
147
+ single_block = dtype == "int64" and dtype_backend == "numpy"
152
148
df = DataFrame (
153
149
{"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ], "c" : np .array ([7 , 8 , 9 ], dtype = dtype )}
154
150
)
@@ -176,7 +172,7 @@ def test_subset_column_slice(
176
172
tm .assert_frame_equal (subset , expected )
177
173
# original parent dataframe is not modified (also not for BlockManager case,
178
174
# except for single block)
179
- if not using_copy_on_write and ( using_array_manager or single_block ) :
175
+ if not using_copy_on_write and single_block :
180
176
df_orig .iloc [0 , 1 ] = 0
181
177
tm .assert_frame_equal (df , df_orig )
182
178
else :
@@ -201,7 +197,6 @@ def test_subset_loc_rows_columns(
201
197
dtype ,
202
198
row_indexer ,
203
199
column_indexer ,
204
- using_array_manager ,
205
200
using_copy_on_write ,
206
201
warn_copy_on_write ,
207
202
):
@@ -224,14 +219,7 @@ def test_subset_loc_rows_columns(
224
219
mutate_parent = (
225
220
isinstance (row_indexer , slice )
226
221
and isinstance (column_indexer , slice )
227
- and (
228
- using_array_manager
229
- or (
230
- dtype == "int64"
231
- and dtype_backend == "numpy"
232
- and not using_copy_on_write
233
- )
234
- )
222
+ and (dtype == "int64" and dtype_backend == "numpy" and not using_copy_on_write )
235
223
)
236
224
237
225
# modifying the subset never modifies the parent
@@ -265,7 +253,6 @@ def test_subset_iloc_rows_columns(
265
253
dtype ,
266
254
row_indexer ,
267
255
column_indexer ,
268
- using_array_manager ,
269
256
using_copy_on_write ,
270
257
warn_copy_on_write ,
271
258
):
@@ -288,14 +275,7 @@ def test_subset_iloc_rows_columns(
288
275
mutate_parent = (
289
276
isinstance (row_indexer , slice )
290
277
and isinstance (column_indexer , slice )
291
- and (
292
- using_array_manager
293
- or (
294
- dtype == "int64"
295
- and dtype_backend == "numpy"
296
- and not using_copy_on_write
297
- )
298
- )
278
+ and (dtype == "int64" and dtype_backend == "numpy" and not using_copy_on_write )
299
279
)
300
280
301
281
# modifying the subset never modifies the parent
@@ -422,7 +402,7 @@ def test_subset_set_column(backend, using_copy_on_write, warn_copy_on_write):
422
402
"dtype" , ["int64" , "float64" ], ids = ["single-block" , "mixed-block" ]
423
403
)
424
404
def test_subset_set_column_with_loc (
425
- backend , using_copy_on_write , warn_copy_on_write , using_array_manager , dtype
405
+ backend , using_copy_on_write , warn_copy_on_write , dtype
426
406
):
427
407
# Case: setting a single column with loc on a viewing subset
428
408
# -> subset.loc[:, col] = value
@@ -440,10 +420,7 @@ def test_subset_set_column_with_loc(
440
420
subset .loc [:, "a" ] = np .array ([10 , 11 ], dtype = "int64" )
441
421
else :
442
422
with pd .option_context ("chained_assignment" , "warn" ):
443
- with tm .assert_produces_warning (
444
- None ,
445
- raise_on_extra_warnings = not using_array_manager ,
446
- ):
423
+ with tm .assert_produces_warning (None ):
447
424
subset .loc [:, "a" ] = np .array ([10 , 11 ], dtype = "int64" )
448
425
449
426
subset ._mgr ._verify_integrity ()
@@ -461,9 +438,7 @@ def test_subset_set_column_with_loc(
461
438
tm .assert_frame_equal (df , df_orig )
462
439
463
440
464
- def test_subset_set_column_with_loc2 (
465
- backend , using_copy_on_write , warn_copy_on_write , using_array_manager
466
- ):
441
+ def test_subset_set_column_with_loc2 (backend , using_copy_on_write , warn_copy_on_write ):
467
442
# Case: setting a single column with loc on a viewing subset
468
443
# -> subset.loc[:, col] = value
469
444
# separate test for case of DataFrame of a single column -> takes a separate
@@ -480,10 +455,7 @@ def test_subset_set_column_with_loc2(
480
455
subset .loc [:, "a" ] = 0
481
456
else :
482
457
with pd .option_context ("chained_assignment" , "warn" ):
483
- with tm .assert_produces_warning (
484
- None ,
485
- raise_on_extra_warnings = not using_array_manager ,
486
- ):
458
+ with tm .assert_produces_warning (None ):
487
459
subset .loc [:, "a" ] = 0
488
460
489
461
subset ._mgr ._verify_integrity ()
@@ -600,7 +572,6 @@ def test_subset_chained_getitem(
600
572
method ,
601
573
dtype ,
602
574
using_copy_on_write ,
603
- using_array_manager ,
604
575
warn_copy_on_write ,
605
576
):
606
577
# Case: creating a subset using multiple, chained getitem calls using views
@@ -614,17 +585,10 @@ def test_subset_chained_getitem(
614
585
# when not using CoW, it depends on whether we have a single block or not
615
586
# and whether we are slicing the columns -> in that case we have a view
616
587
test_callspec = request .node .callspec .id
617
- if not using_array_manager :
618
- subset_is_view = test_callspec in (
619
- "numpy-single-block-column-iloc-slice" ,
620
- "numpy-single-block-column-loc-slice" ,
621
- )
622
- else :
623
- # with ArrayManager, it doesn't matter whether we have
624
- # single vs mixed block or numpy vs nullable dtypes
625
- subset_is_view = test_callspec .endswith (
626
- ("column-iloc-slice" , "column-loc-slice" )
627
- )
588
+ subset_is_view = test_callspec in (
589
+ "numpy-single-block-column-iloc-slice" ,
590
+ "numpy-single-block-column-loc-slice" ,
591
+ )
628
592
629
593
# modify subset -> don't modify parent
630
594
subset = method (df )
@@ -726,9 +690,7 @@ def test_subset_chained_getitem_series(
726
690
assert subset .iloc [0 ] == 0
727
691
728
692
729
- def test_subset_chained_single_block_row (
730
- using_copy_on_write , using_array_manager , warn_copy_on_write
731
- ):
693
+ def test_subset_chained_single_block_row (using_copy_on_write , warn_copy_on_write ):
732
694
# not parametrizing this for dtype backend, since this explicitly tests single block
733
695
df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ], "c" : [7 , 8 , 9 ]})
734
696
df_orig = df .copy ()
@@ -737,7 +699,7 @@ def test_subset_chained_single_block_row(
737
699
subset = df [:].iloc [0 ].iloc [0 :2 ]
738
700
with tm .assert_cow_warning (warn_copy_on_write ):
739
701
subset .iloc [0 ] = 0
740
- if using_copy_on_write or using_array_manager :
702
+ if using_copy_on_write :
741
703
tm .assert_frame_equal (df , df_orig )
742
704
else :
743
705
assert df .iloc [0 , 0 ] == 0
@@ -747,7 +709,7 @@ def test_subset_chained_single_block_row(
747
709
with tm .assert_cow_warning (warn_copy_on_write ):
748
710
df .iloc [0 , 0 ] = 0
749
711
expected = Series ([1 , 4 ], index = ["a" , "b" ], name = 0 )
750
- if using_copy_on_write or using_array_manager :
712
+ if using_copy_on_write :
751
713
tm .assert_series_equal (subset , expected )
752
714
else :
753
715
assert subset .iloc [0 ] == 0
@@ -967,9 +929,7 @@ def test_del_series(backend):
967
929
# Accessing column as Series
968
930
969
931
970
- def test_column_as_series (
971
- backend , using_copy_on_write , warn_copy_on_write , using_array_manager
972
- ):
932
+ def test_column_as_series (backend , using_copy_on_write , warn_copy_on_write ):
973
933
# Case: selecting a single column now also uses Copy-on-Write
974
934
dtype_backend , DataFrame , Series = backend
975
935
df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ], "c" : [0.1 , 0.2 , 0.3 ]})
@@ -979,7 +939,7 @@ def test_column_as_series(
979
939
980
940
assert np .shares_memory (get_array (s , "a" ), get_array (df , "a" ))
981
941
982
- if using_copy_on_write or using_array_manager :
942
+ if using_copy_on_write :
983
943
s [0 ] = 0
984
944
else :
985
945
if warn_copy_on_write :
@@ -1004,7 +964,7 @@ def test_column_as_series(
1004
964
1005
965
1006
966
def test_column_as_series_set_with_upcast (
1007
- backend , using_copy_on_write , using_array_manager , warn_copy_on_write
967
+ backend , using_copy_on_write , warn_copy_on_write
1008
968
):
1009
969
# Case: selecting a single column now also uses Copy-on-Write -> when
1010
970
# setting a value causes an upcast, we don't need to update the parent
@@ -1019,7 +979,7 @@ def test_column_as_series_set_with_upcast(
1019
979
with pytest .raises (TypeError , match = "Invalid value" ):
1020
980
s [0 ] = "foo"
1021
981
expected = Series ([1 , 2 , 3 ], name = "a" )
1022
- elif using_copy_on_write or warn_copy_on_write or using_array_manager :
982
+ elif using_copy_on_write or warn_copy_on_write :
1023
983
# TODO(CoW-warn) assert the FutureWarning for CoW is also raised
1024
984
with tm .assert_produces_warning (FutureWarning , match = "incompatible dtype" ):
1025
985
s [0 ] = "foo"
@@ -1063,7 +1023,6 @@ def test_column_as_series_no_item_cache(
1063
1023
method ,
1064
1024
using_copy_on_write ,
1065
1025
warn_copy_on_write ,
1066
- using_array_manager ,
1067
1026
):
1068
1027
# Case: selecting a single column (which now also uses Copy-on-Write to protect
1069
1028
# the view) should always give a new object (i.e. not make use of a cache)
@@ -1080,7 +1039,7 @@ def test_column_as_series_no_item_cache(
1080
1039
else :
1081
1040
assert s1 is s2
1082
1041
1083
- if using_copy_on_write or using_array_manager :
1042
+ if using_copy_on_write :
1084
1043
s1 .iloc [0 ] = 0
1085
1044
elif warn_copy_on_write :
1086
1045
with tm .assert_cow_warning ():
@@ -1181,18 +1140,15 @@ def test_series_midx_slice(using_copy_on_write, warn_copy_on_write):
1181
1140
tm .assert_series_equal (ser , expected )
1182
1141
1183
1142
1184
- def test_getitem_midx_slice (
1185
- using_copy_on_write , warn_copy_on_write , using_array_manager
1186
- ):
1143
+ def test_getitem_midx_slice (using_copy_on_write , warn_copy_on_write ):
1187
1144
df = DataFrame ({("a" , "x" ): [1 , 2 ], ("a" , "y" ): 1 , ("b" , "x" ): 2 })
1188
1145
df_orig = df .copy ()
1189
1146
new_df = df [("a" ,)]
1190
1147
1191
1148
if using_copy_on_write :
1192
1149
assert not new_df ._mgr ._has_no_reference (0 )
1193
1150
1194
- if not using_array_manager :
1195
- assert np .shares_memory (get_array (df , ("a" , "x" )), get_array (new_df , "x" ))
1151
+ assert np .shares_memory (get_array (df , ("a" , "x" )), get_array (new_df , "x" ))
1196
1152
if using_copy_on_write :
1197
1153
new_df .iloc [0 , 0 ] = 100
1198
1154
tm .assert_frame_equal (df_orig , df )
0 commit comments