@@ -251,18 +251,19 @@ def test_set_frame_axis(using_copy_on_write):
251
251
assert not np .shares_memory (get_array (df2 , "b" ), get_array (df , "b" ))
252
252
tm .assert_frame_equal (df , df_orig )
253
253
254
+
254
255
def test_set_series_axis (using_copy_on_write ):
255
256
# GH 49473
256
257
ser = Series ([1 , 2 , 3 ])
257
258
ser_orig = ser .copy ()
258
- ser = ser .set_axis (["a" , "b" , "c" ], axis = "index" )
259
+ ser2 = ser .set_axis (["a" , "b" , "c" ], axis = "index" )
259
260
260
261
if using_copy_on_write :
261
- assert np .shares_memory (get_array ( ser , "a" ), get_array ( ser , "a" ) )
262
+ assert np .shares_memory (ser , ser2 )
262
263
else :
263
- assert not np .shares_memory (get_array ( ser , "a" ), get_array ( ser , "a" ) )
264
+ assert not np .shares_memory (ser , ser2 )
264
265
265
266
# mutating ser triggers a copy-on-write for that column / block
266
- ser .iloc [0 , 0 ] = 0
267
- assert not np .shares_memory (get_array ( ser , "b" ), get_array ( ser , "b" ) )
268
- tm .assert_frame_equal (ser , ser_orig )
267
+ ser2 .iloc [0 ] = 0
268
+ assert not np .shares_memory (ser2 , ser )
269
+ tm .assert_series_equal (ser , ser_orig )
0 commit comments