1010import pandas ._testing as tm
1111
1212
13- def monotonic_index (start , end , dtype = "int64" , closed = "right" ):
13+ def monotonic_index (start , end , dtype = "int64" , inclusive = "right" ):
1414 return IntervalIndex .from_breaks (
15- np .arange (start , end , dtype = dtype ), inclusive = closed
15+ np .arange (start , end , dtype = dtype ), inclusive = inclusive
1616 )
1717
1818
19- def empty_index (dtype = "int64" , closed = "right" ):
20- return IntervalIndex (np .array ([], dtype = dtype ), inclusive = closed )
19+ def empty_index (dtype = "int64" , inclusive = "right" ):
20+ return IntervalIndex (np .array ([], dtype = dtype ), inclusive = inclusive )
2121
2222
2323class TestIntervalIndex :
2424 def test_union (self , closed , sort ):
25- index = monotonic_index (0 , 11 , closed = closed )
26- other = monotonic_index (5 , 13 , closed = closed )
25+ index = monotonic_index (0 , 11 , inclusive = closed )
26+ other = monotonic_index (5 , 13 , inclusive = closed )
2727
28- expected = monotonic_index (0 , 13 , closed = closed )
28+ expected = monotonic_index (0 , 13 , inclusive = closed )
2929 result = index [::- 1 ].union (other , sort = sort )
3030 if sort is None :
3131 tm .assert_index_equal (result , expected )
@@ -41,31 +41,31 @@ def test_union(self, closed, sort):
4141
4242 def test_union_empty_result (self , closed , sort ):
4343 # GH 19101: empty result, same dtype
44- index = empty_index (dtype = "int64" , closed = closed )
44+ index = empty_index (dtype = "int64" , inclusive = closed )
4545 result = index .union (index , sort = sort )
4646 tm .assert_index_equal (result , index )
4747
4848 # GH 19101: empty result, different numeric dtypes -> common dtype is f8
49- other = empty_index (dtype = "float64" , closed = closed )
49+ other = empty_index (dtype = "float64" , inclusive = closed )
5050 result = index .union (other , sort = sort )
5151 expected = other
5252 tm .assert_index_equal (result , expected )
5353
5454 other = index .union (index , sort = sort )
5555 tm .assert_index_equal (result , expected )
5656
57- other = empty_index (dtype = "uint64" , closed = closed )
57+ other = empty_index (dtype = "uint64" , inclusive = closed )
5858 result = index .union (other , sort = sort )
5959 tm .assert_index_equal (result , expected )
6060
6161 result = other .union (index , sort = sort )
6262 tm .assert_index_equal (result , expected )
6363
6464 def test_intersection (self , closed , sort ):
65- index = monotonic_index (0 , 11 , closed = closed )
66- other = monotonic_index (5 , 13 , closed = closed )
65+ index = monotonic_index (0 , 11 , inclusive = closed )
66+ other = monotonic_index (5 , 13 , inclusive = closed )
6767
68- expected = monotonic_index (5 , 11 , closed = closed )
68+ expected = monotonic_index (5 , 11 , inclusive = closed )
6969 result = index [::- 1 ].intersection (other , sort = sort )
7070 if sort is None :
7171 tm .assert_index_equal (result , expected )
@@ -100,21 +100,21 @@ def test_intersection(self, closed, sort):
100100 tm .assert_index_equal (result , expected )
101101
102102 def test_intersection_empty_result (self , closed , sort ):
103- index = monotonic_index (0 , 11 , closed = closed )
103+ index = monotonic_index (0 , 11 , inclusive = closed )
104104
105105 # GH 19101: empty result, same dtype
106- other = monotonic_index (300 , 314 , closed = closed )
107- expected = empty_index (dtype = "int64" , closed = closed )
106+ other = monotonic_index (300 , 314 , inclusive = closed )
107+ expected = empty_index (dtype = "int64" , inclusive = closed )
108108 result = index .intersection (other , sort = sort )
109109 tm .assert_index_equal (result , expected )
110110
111111 # GH 19101: empty result, different numeric dtypes -> common dtype is float64
112- other = monotonic_index (300 , 314 , dtype = "float64" , closed = closed )
112+ other = monotonic_index (300 , 314 , dtype = "float64" , inclusive = closed )
113113 result = index .intersection (other , sort = sort )
114114 expected = other [:0 ]
115115 tm .assert_index_equal (result , expected )
116116
117- other = monotonic_index (300 , 314 , dtype = "uint64" , closed = closed )
117+ other = monotonic_index (300 , 314 , dtype = "uint64" , inclusive = closed )
118118 result = index .intersection (other , sort = sort )
119119 tm .assert_index_equal (result , expected )
120120
@@ -136,7 +136,7 @@ def test_difference(self, closed, sort):
136136
137137 # GH 19101: empty result, same dtype
138138 result = index .difference (index , sort = sort )
139- expected = empty_index (dtype = "int64" , closed = closed )
139+ expected = empty_index (dtype = "int64" , inclusive = closed )
140140 tm .assert_index_equal (result , expected )
141141
142142 # GH 19101: empty result, different dtypes
@@ -147,7 +147,7 @@ def test_difference(self, closed, sort):
147147 tm .assert_index_equal (result , expected )
148148
149149 def test_symmetric_difference (self , closed , sort ):
150- index = monotonic_index (0 , 11 , closed = closed )
150+ index = monotonic_index (0 , 11 , inclusive = closed )
151151 result = index [1 :].symmetric_difference (index [:- 1 ], sort = sort )
152152 expected = IntervalIndex ([index [0 ], index [- 1 ]])
153153 if sort is None :
@@ -156,7 +156,7 @@ def test_symmetric_difference(self, closed, sort):
156156
157157 # GH 19101: empty result, same dtype
158158 result = index .symmetric_difference (index , sort = sort )
159- expected = empty_index (dtype = "int64" , closed = closed )
159+ expected = empty_index (dtype = "int64" , inclusive = closed )
160160 if sort is None :
161161 tm .assert_index_equal (result , expected )
162162 assert tm .equalContents (result , expected )
@@ -166,15 +166,15 @@ def test_symmetric_difference(self, closed, sort):
166166 index .left .astype ("float64" ), index .right , inclusive = closed
167167 )
168168 result = index .symmetric_difference (other , sort = sort )
169- expected = empty_index (dtype = "float64" , closed = closed )
169+ expected = empty_index (dtype = "float64" , inclusive = closed )
170170 tm .assert_index_equal (result , expected )
171171
172172 @pytest .mark .filterwarnings ("ignore:'<' not supported between:RuntimeWarning" )
173173 @pytest .mark .parametrize (
174174 "op_name" , ["union" , "intersection" , "difference" , "symmetric_difference" ]
175175 )
176176 def test_set_incompatible_types (self , closed , op_name , sort ):
177- index = monotonic_index (0 , 11 , closed = closed )
177+ index = monotonic_index (0 , 11 , inclusive = closed )
178178 set_op = getattr (index , op_name )
179179
180180 # TODO: standardize return type of non-union setops type(self vs other)
@@ -187,8 +187,8 @@ def test_set_incompatible_types(self, closed, op_name, sort):
187187 tm .assert_index_equal (result , expected )
188188
189189 # mixed closed -> cast to object
190- for other_closed in {"right" , "left" , "both" , "neither" } - {closed }:
191- other = monotonic_index (0 , 11 , closed = other_closed )
190+ for other_inclusive in {"right" , "left" , "both" , "neither" } - {closed }:
191+ other = monotonic_index (0 , 11 , inclusive = other_inclusive )
192192 expected = getattr (index .astype (object ), op_name )(other , sort = sort )
193193 if op_name == "difference" :
194194 expected = index
0 commit comments