Skip to content

Commit a1330fb

Browse files
committed
fix test for series axis
1 parent 9d7bfa5 commit a1330fb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pandas/tests/copy_view/test_methods.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,19 @@ def test_set_frame_axis(using_copy_on_write):
251251
assert not np.shares_memory(get_array(df2, "b"), get_array(df, "b"))
252252
tm.assert_frame_equal(df, df_orig)
253253

254+
254255
def test_set_series_axis(using_copy_on_write):
255256
# GH 49473
256257
ser = Series([1, 2, 3])
257258
ser_orig = ser.copy()
258-
ser = ser.set_axis(["a", "b", "c"], axis="index")
259+
ser2 = ser.set_axis(["a", "b", "c"], axis="index")
259260

260261
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)
262263
else:
263-
assert not np.shares_memory(get_array(ser, "a"), get_array(ser, "a"))
264+
assert not np.shares_memory(ser, ser2)
264265

265266
# 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

Comments
 (0)