@@ -19,18 +19,15 @@ def index_view(index_data):
1919 return idx , view
2020
2121
22- def test_set_index_update_column (using_copy_on_write ):
22+ def test_set_index_update_column ():
2323 df = DataFrame ({"a" : [1 , 2 ], "b" : 1 })
2424 df = df .set_index ("a" , drop = False )
2525 expected = df .index .copy (deep = True )
2626 df .iloc [0 , 0 ] = 100
27- if using_copy_on_write :
28- tm .assert_index_equal (df .index , expected )
29- else :
30- tm .assert_index_equal (df .index , Index ([100 , 2 ], name = "a" ))
27+ tm .assert_index_equal (df .index , expected )
3128
3229
33- def test_set_index_drop_update_column (using_copy_on_write ):
30+ def test_set_index_drop_update_column ():
3431 df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
3532 view = df [:]
3633 df = df .set_index ("a" , drop = True )
@@ -39,73 +36,58 @@ def test_set_index_drop_update_column(using_copy_on_write):
3936 tm .assert_index_equal (df .index , expected )
4037
4138
42- def test_set_index_series (using_copy_on_write ):
39+ def test_set_index_series ():
4340 df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
4441 ser = Series ([10 , 11 ])
4542 df = df .set_index (ser )
4643 expected = df .index .copy (deep = True )
4744 ser .iloc [0 ] = 100
48- if using_copy_on_write :
49- tm .assert_index_equal (df .index , expected )
50- else :
51- tm .assert_index_equal (df .index , Index ([100 , 11 ]))
45+ tm .assert_index_equal (df .index , expected )
5246
5347
54- def test_assign_index_as_series (using_copy_on_write ):
48+ def test_assign_index_as_series ():
5549 df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
5650 ser = Series ([10 , 11 ])
5751 df .index = ser
5852 expected = df .index .copy (deep = True )
5953 ser .iloc [0 ] = 100
60- if using_copy_on_write :
61- tm .assert_index_equal (df .index , expected )
62- else :
63- tm .assert_index_equal (df .index , Index ([100 , 11 ]))
54+ tm .assert_index_equal (df .index , expected )
6455
6556
66- def test_assign_index_as_index (using_copy_on_write ):
57+ def test_assign_index_as_index ():
6758 df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
6859 ser = Series ([10 , 11 ])
6960 rhs_index = Index (ser )
7061 df .index = rhs_index
7162 rhs_index = None # overwrite to clear reference
7263 expected = df .index .copy (deep = True )
7364 ser .iloc [0 ] = 100
74- if using_copy_on_write :
75- tm .assert_index_equal (df .index , expected )
76- else :
77- tm .assert_index_equal (df .index , Index ([100 , 11 ]))
65+ tm .assert_index_equal (df .index , expected )
7866
7967
80- def test_index_from_series (using_copy_on_write ):
68+ def test_index_from_series ():
8169 ser = Series ([1 , 2 ])
8270 idx = Index (ser )
8371 expected = idx .copy (deep = True )
8472 ser .iloc [0 ] = 100
85- if using_copy_on_write :
86- tm .assert_index_equal (idx , expected )
87- else :
88- tm .assert_index_equal (idx , Index ([100 , 2 ]))
73+ tm .assert_index_equal (idx , expected )
8974
9075
91- def test_index_from_series_copy (using_copy_on_write ):
76+ def test_index_from_series_copy ():
9277 ser = Series ([1 , 2 ])
9378 idx = Index (ser , copy = True ) # noqa: F841
9479 arr = get_array (ser )
9580 ser .iloc [0 ] = 100
9681 assert np .shares_memory (get_array (ser ), arr )
9782
9883
99- def test_index_from_index (using_copy_on_write ):
84+ def test_index_from_index ():
10085 ser = Series ([1 , 2 ])
10186 idx = Index (ser )
10287 idx = Index (idx )
10388 expected = idx .copy (deep = True )
10489 ser .iloc [0 ] = 100
105- if using_copy_on_write :
106- tm .assert_index_equal (idx , expected )
107- else :
108- tm .assert_index_equal (idx , Index ([100 , 2 ]))
90+ tm .assert_index_equal (idx , expected )
10991
11092
11193@pytest .mark .parametrize (
@@ -135,44 +117,36 @@ def test_index_from_index(using_copy_on_write):
135117 "astype" ,
136118 ],
137119)
138- def test_index_ops (using_copy_on_write , func , request ):
120+ def test_index_ops (func , request ):
139121 idx , view_ = index_view ([1 , 2 ])
140122 expected = idx .copy (deep = True )
141123 if "astype" in request .node .callspec .id :
142124 expected = expected .astype ("Int64" )
143125 idx = func (idx )
144126 view_ .iloc [0 , 0 ] = 100
145- if using_copy_on_write :
146- tm .assert_index_equal (idx , expected , check_names = False )
127+ tm .assert_index_equal (idx , expected , check_names = False )
147128
148129
149- def test_infer_objects (using_copy_on_write ):
130+ def test_infer_objects ():
150131 idx , view_ = index_view (["a" , "b" ])
151132 expected = idx .copy (deep = True )
152133 idx = idx .infer_objects (copy = False )
153134 view_ .iloc [0 , 0 ] = "aaaa"
154- if using_copy_on_write :
155- tm .assert_index_equal (idx , expected , check_names = False )
135+ tm .assert_index_equal (idx , expected , check_names = False )
156136
157137
158- def test_index_to_frame (using_copy_on_write ):
138+ def test_index_to_frame ():
159139 idx = Index ([1 , 2 , 3 ], name = "a" )
160140 expected = idx .copy (deep = True )
161141 df = idx .to_frame ()
162- if using_copy_on_write :
163- assert np .shares_memory (get_array (df , "a" ), idx ._values )
164- assert not df ._mgr ._has_no_reference (0 )
165- else :
166- assert not np .shares_memory (get_array (df , "a" ), idx ._values )
142+ assert np .shares_memory (get_array (df , "a" ), idx ._values )
143+ assert not df ._mgr ._has_no_reference (0 )
167144
168145 df .iloc [0 , 0 ] = 100
169146 tm .assert_index_equal (idx , expected )
170147
171148
172- def test_index_values (using_copy_on_write ):
149+ def test_index_values ():
173150 idx = Index ([1 , 2 , 3 ])
174151 result = idx .values
175- if using_copy_on_write :
176- assert result .flags .writeable is False
177- else :
178- assert result .flags .writeable is True
152+ assert result .flags .writeable is False
0 commit comments