@@ -19,18 +19,15 @@ def index_view(index_data):
19
19
return idx , view
20
20
21
21
22
- def test_set_index_update_column (using_copy_on_write ):
22
+ def test_set_index_update_column ():
23
23
df = DataFrame ({"a" : [1 , 2 ], "b" : 1 })
24
24
df = df .set_index ("a" , drop = False )
25
25
expected = df .index .copy (deep = True )
26
26
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 )
31
28
32
29
33
- def test_set_index_drop_update_column (using_copy_on_write ):
30
+ def test_set_index_drop_update_column ():
34
31
df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
35
32
view = df [:]
36
33
df = df .set_index ("a" , drop = True )
@@ -39,73 +36,58 @@ def test_set_index_drop_update_column(using_copy_on_write):
39
36
tm .assert_index_equal (df .index , expected )
40
37
41
38
42
- def test_set_index_series (using_copy_on_write ):
39
+ def test_set_index_series ():
43
40
df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
44
41
ser = Series ([10 , 11 ])
45
42
df = df .set_index (ser )
46
43
expected = df .index .copy (deep = True )
47
44
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 )
52
46
53
47
54
- def test_assign_index_as_series (using_copy_on_write ):
48
+ def test_assign_index_as_series ():
55
49
df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
56
50
ser = Series ([10 , 11 ])
57
51
df .index = ser
58
52
expected = df .index .copy (deep = True )
59
53
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 )
64
55
65
56
66
- def test_assign_index_as_index (using_copy_on_write ):
57
+ def test_assign_index_as_index ():
67
58
df = DataFrame ({"a" : [1 , 2 ], "b" : 1.5 })
68
59
ser = Series ([10 , 11 ])
69
60
rhs_index = Index (ser )
70
61
df .index = rhs_index
71
62
rhs_index = None # overwrite to clear reference
72
63
expected = df .index .copy (deep = True )
73
64
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 )
78
66
79
67
80
- def test_index_from_series (using_copy_on_write ):
68
+ def test_index_from_series ():
81
69
ser = Series ([1 , 2 ])
82
70
idx = Index (ser )
83
71
expected = idx .copy (deep = True )
84
72
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 )
89
74
90
75
91
- def test_index_from_series_copy (using_copy_on_write ):
76
+ def test_index_from_series_copy ():
92
77
ser = Series ([1 , 2 ])
93
78
idx = Index (ser , copy = True ) # noqa: F841
94
79
arr = get_array (ser )
95
80
ser .iloc [0 ] = 100
96
81
assert np .shares_memory (get_array (ser ), arr )
97
82
98
83
99
- def test_index_from_index (using_copy_on_write ):
84
+ def test_index_from_index ():
100
85
ser = Series ([1 , 2 ])
101
86
idx = Index (ser )
102
87
idx = Index (idx )
103
88
expected = idx .copy (deep = True )
104
89
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 )
109
91
110
92
111
93
@pytest .mark .parametrize (
@@ -135,44 +117,36 @@ def test_index_from_index(using_copy_on_write):
135
117
"astype" ,
136
118
],
137
119
)
138
- def test_index_ops (using_copy_on_write , func , request ):
120
+ def test_index_ops (func , request ):
139
121
idx , view_ = index_view ([1 , 2 ])
140
122
expected = idx .copy (deep = True )
141
123
if "astype" in request .node .callspec .id :
142
124
expected = expected .astype ("Int64" )
143
125
idx = func (idx )
144
126
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 )
147
128
148
129
149
- def test_infer_objects (using_copy_on_write ):
130
+ def test_infer_objects ():
150
131
idx , view_ = index_view (["a" , "b" ])
151
132
expected = idx .copy (deep = True )
152
133
idx = idx .infer_objects (copy = False )
153
134
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 )
156
136
157
137
158
- def test_index_to_frame (using_copy_on_write ):
138
+ def test_index_to_frame ():
159
139
idx = Index ([1 , 2 , 3 ], name = "a" )
160
140
expected = idx .copy (deep = True )
161
141
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 )
167
144
168
145
df .iloc [0 , 0 ] = 100
169
146
tm .assert_index_equal (idx , expected )
170
147
171
148
172
- def test_index_values (using_copy_on_write ):
149
+ def test_index_values ():
173
150
idx = Index ([1 , 2 , 3 ])
174
151
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