@@ -140,15 +140,11 @@ def test_subset_row_slice(backend, using_copy_on_write, warn_copy_on_write):
140140@pytest .mark .parametrize (
141141 "dtype" , ["int64" , "float64" ], ids = ["single-block" , "mixed-block" ]
142142)
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 ):
146144 # Case: taking a subset of the columns of a DataFrame using a slice
147145 # + afterwards modifying the subset
148146 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"
152148 df = DataFrame (
153149 {"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ], "c" : np .array ([7 , 8 , 9 ], dtype = dtype )}
154150 )
@@ -176,7 +172,7 @@ def test_subset_column_slice(
176172 tm .assert_frame_equal (subset , expected )
177173 # original parent dataframe is not modified (also not for BlockManager case,
178174 # 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 :
180176 df_orig .iloc [0 , 1 ] = 0
181177 tm .assert_frame_equal (df , df_orig )
182178 else :
@@ -201,7 +197,6 @@ def test_subset_loc_rows_columns(
201197 dtype ,
202198 row_indexer ,
203199 column_indexer ,
204- using_array_manager ,
205200 using_copy_on_write ,
206201 warn_copy_on_write ,
207202):
@@ -224,14 +219,7 @@ def test_subset_loc_rows_columns(
224219 mutate_parent = (
225220 isinstance (row_indexer , slice )
226221 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 )
235223 )
236224
237225 # modifying the subset never modifies the parent
@@ -265,7 +253,6 @@ def test_subset_iloc_rows_columns(
265253 dtype ,
266254 row_indexer ,
267255 column_indexer ,
268- using_array_manager ,
269256 using_copy_on_write ,
270257 warn_copy_on_write ,
271258):
@@ -288,14 +275,7 @@ def test_subset_iloc_rows_columns(
288275 mutate_parent = (
289276 isinstance (row_indexer , slice )
290277 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 )
299279 )
300280
301281 # 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):
422402 "dtype" , ["int64" , "float64" ], ids = ["single-block" , "mixed-block" ]
423403)
424404def 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
426406):
427407 # Case: setting a single column with loc on a viewing subset
428408 # -> subset.loc[:, col] = value
@@ -440,10 +420,7 @@ def test_subset_set_column_with_loc(
440420 subset .loc [:, "a" ] = np .array ([10 , 11 ], dtype = "int64" )
441421 else :
442422 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 ):
447424 subset .loc [:, "a" ] = np .array ([10 , 11 ], dtype = "int64" )
448425
449426 subset ._mgr ._verify_integrity ()
@@ -461,9 +438,7 @@ def test_subset_set_column_with_loc(
461438 tm .assert_frame_equal (df , df_orig )
462439
463440
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 ):
467442 # Case: setting a single column with loc on a viewing subset
468443 # -> subset.loc[:, col] = value
469444 # separate test for case of DataFrame of a single column -> takes a separate
@@ -480,10 +455,7 @@ def test_subset_set_column_with_loc2(
480455 subset .loc [:, "a" ] = 0
481456 else :
482457 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 ):
487459 subset .loc [:, "a" ] = 0
488460
489461 subset ._mgr ._verify_integrity ()
@@ -600,7 +572,6 @@ def test_subset_chained_getitem(
600572 method ,
601573 dtype ,
602574 using_copy_on_write ,
603- using_array_manager ,
604575 warn_copy_on_write ,
605576):
606577 # Case: creating a subset using multiple, chained getitem calls using views
@@ -614,17 +585,10 @@ def test_subset_chained_getitem(
614585 # when not using CoW, it depends on whether we have a single block or not
615586 # and whether we are slicing the columns -> in that case we have a view
616587 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+ )
628592
629593 # modify subset -> don't modify parent
630594 subset = method (df )
@@ -726,9 +690,7 @@ def test_subset_chained_getitem_series(
726690 assert subset .iloc [0 ] == 0
727691
728692
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 ):
732694 # not parametrizing this for dtype backend, since this explicitly tests single block
733695 df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ], "c" : [7 , 8 , 9 ]})
734696 df_orig = df .copy ()
@@ -737,7 +699,7 @@ def test_subset_chained_single_block_row(
737699 subset = df [:].iloc [0 ].iloc [0 :2 ]
738700 with tm .assert_cow_warning (warn_copy_on_write ):
739701 subset .iloc [0 ] = 0
740- if using_copy_on_write or using_array_manager :
702+ if using_copy_on_write :
741703 tm .assert_frame_equal (df , df_orig )
742704 else :
743705 assert df .iloc [0 , 0 ] == 0
@@ -747,7 +709,7 @@ def test_subset_chained_single_block_row(
747709 with tm .assert_cow_warning (warn_copy_on_write ):
748710 df .iloc [0 , 0 ] = 0
749711 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 :
751713 tm .assert_series_equal (subset , expected )
752714 else :
753715 assert subset .iloc [0 ] == 0
@@ -967,9 +929,7 @@ def test_del_series(backend):
967929# Accessing column as Series
968930
969931
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 ):
973933 # Case: selecting a single column now also uses Copy-on-Write
974934 dtype_backend , DataFrame , Series = backend
975935 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(
979939
980940 assert np .shares_memory (get_array (s , "a" ), get_array (df , "a" ))
981941
982- if using_copy_on_write or using_array_manager :
942+ if using_copy_on_write :
983943 s [0 ] = 0
984944 else :
985945 if warn_copy_on_write :
@@ -1004,7 +964,7 @@ def test_column_as_series(
1004964
1005965
1006966def 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
1008968):
1009969 # Case: selecting a single column now also uses Copy-on-Write -> when
1010970 # 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(
1019979 with pytest .raises (TypeError , match = "Invalid value" ):
1020980 s [0 ] = "foo"
1021981 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 :
1023983 # TODO(CoW-warn) assert the FutureWarning for CoW is also raised
1024984 with tm .assert_produces_warning (FutureWarning , match = "incompatible dtype" ):
1025985 s [0 ] = "foo"
@@ -1063,7 +1023,6 @@ def test_column_as_series_no_item_cache(
10631023 method ,
10641024 using_copy_on_write ,
10651025 warn_copy_on_write ,
1066- using_array_manager ,
10671026):
10681027 # Case: selecting a single column (which now also uses Copy-on-Write to protect
10691028 # 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(
10801039 else :
10811040 assert s1 is s2
10821041
1083- if using_copy_on_write or using_array_manager :
1042+ if using_copy_on_write :
10841043 s1 .iloc [0 ] = 0
10851044 elif warn_copy_on_write :
10861045 with tm .assert_cow_warning ():
@@ -1181,18 +1140,15 @@ def test_series_midx_slice(using_copy_on_write, warn_copy_on_write):
11811140 tm .assert_series_equal (ser , expected )
11821141
11831142
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 ):
11871144 df = DataFrame ({("a" , "x" ): [1 , 2 ], ("a" , "y" ): 1 , ("b" , "x" ): 2 })
11881145 df_orig = df .copy ()
11891146 new_df = df [("a" ,)]
11901147
11911148 if using_copy_on_write :
11921149 assert not new_df ._mgr ._has_no_reference (0 )
11931150
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" ))
11961152 if using_copy_on_write :
11971153 new_df .iloc [0 , 0 ] = 100
11981154 tm .assert_frame_equal (df_orig , df )
0 commit comments