Skip to content

Commit 923c949

Browse files
TST: Add regression tests for GH#63388 (IntervalIndex copy behavior)
1 parent 1252782 commit 923c949

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import numpy as np
2+
3+
from pandas import (
4+
IntervalIndex,
5+
Series,
6+
Interval,
7+
array,
8+
)
9+
import pandas._testing as tm
10+
from pandas.tests.copy_view.util import get_array
11+
12+
13+
def test_constructor_copy_input_interval_ea_default():
14+
# GH 63388
15+
arr = array([Interval(0, 1), Interval(1, 2)])
16+
idx = IntervalIndex(arr)
17+
assert not tm.shares_memory(arr, idx.array)
18+
19+
20+
def test_series_from_temporary_intervalindex_readonly_data():
21+
# GH 63388
22+
arr = array([Interval(0, 1), Interval(1, 2)])
23+
arr._left.flags.writeable = False
24+
arr._right.flags.writeable = False
25+
ser = Series(IntervalIndex(arr))
26+
assert not np.shares_memory(arr._left, get_array(ser)._left)
27+
ser.iloc[0] = Interval(5, 6)
28+
expected = Series(
29+
[Interval(5, 6), Interval(1, 2)],
30+
dtype='interval[int64, right]'
31+
)
32+
tm.assert_series_equal(ser, expected)

0 commit comments

Comments
 (0)