@@ -20,9 +20,7 @@ def skipif_32bit(param):
20
20
return pytest .param (param , marks = marks )
21
21
22
22
23
- @pytest .fixture (
24
- scope = "class" , params = ["int32" , "int64" , "float32" , "float64" , "uint64" ]
25
- )
23
+ @pytest .fixture (scope = "class" , params = ["int64" , "float64" , "uint64" ])
26
24
def dtype (request ):
27
25
return request .param
28
26
@@ -39,12 +37,9 @@ def leaf_size(request):
39
37
@pytest .fixture (
40
38
params = [
41
39
np .arange (5 , dtype = "int64" ),
42
- np .arange (5 , dtype = "int32" ),
43
40
np .arange (5 , dtype = "uint64" ),
44
41
np .arange (5 , dtype = "float64" ),
45
- np .arange (5 , dtype = "float32" ),
46
42
np .array ([0 , 1 , 2 , 3 , 4 , np .nan ], dtype = "float64" ),
47
- np .array ([0 , 1 , 2 , 3 , 4 , np .nan ], dtype = "float32" ),
48
43
]
49
44
)
50
45
def tree (request , leaf_size ):
@@ -64,13 +59,14 @@ def test_get_indexer(self, tree):
64
59
tree .get_indexer (np .array ([3.0 ]))
65
60
66
61
@pytest .mark .parametrize (
67
- "dtype, target_value" , [("int64" , 2 ** 63 + 1 ), ("uint64" , - 1 )]
62
+ "dtype, target_value, target_dtype" ,
63
+ [("int64" , 2 ** 63 + 1 , "uint64" ), ("uint64" , - 1 , "int64" )],
68
64
)
69
- def test_get_indexer_overflow (self , dtype , target_value ):
65
+ def test_get_indexer_overflow (self , dtype , target_value , target_dtype ):
70
66
left , right = np .array ([0 , 1 ], dtype = dtype ), np .array ([1 , 2 ], dtype = dtype )
71
67
tree = IntervalTree (left , right )
72
68
73
- result = tree .get_indexer (np .array ([target_value ]))
69
+ result = tree .get_indexer (np .array ([target_value ], dtype = target_dtype ))
74
70
expected = np .array ([- 1 ], dtype = "intp" )
75
71
tm .assert_numpy_array_equal (result , expected )
76
72
@@ -94,12 +90,13 @@ def test_get_indexer_non_unique(self, tree):
94
90
tm .assert_numpy_array_equal (result , expected )
95
91
96
92
@pytest .mark .parametrize (
97
- "dtype, target_value" , [("int64" , 2 ** 63 + 1 ), ("uint64" , - 1 )]
93
+ "dtype, target_value, target_dtype" ,
94
+ [("int64" , 2 ** 63 + 1 , "uint64" ), ("uint64" , - 1 , "int64" )],
98
95
)
99
- def test_get_indexer_non_unique_overflow (self , dtype , target_value ):
96
+ def test_get_indexer_non_unique_overflow (self , dtype , target_value , target_dtype ):
100
97
left , right = np .array ([0 , 2 ], dtype = dtype ), np .array ([1 , 3 ], dtype = dtype )
101
98
tree = IntervalTree (left , right )
102
- target = np .array ([target_value ])
99
+ target = np .array ([target_value ], dtype = target_dtype )
103
100
104
101
result_indexer , result_missing = tree .get_indexer_non_unique (target )
105
102
expected_indexer = np .array ([- 1 ], dtype = "intp" )
@@ -146,10 +143,10 @@ def test_get_indexer_closed(self, closed, leaf_size):
146
143
@pytest .mark .parametrize (
147
144
"left, right, expected" ,
148
145
[
149
- (np .array ([0 , 1 , 4 ]), np .array ([2 , 3 , 5 ]), True ),
150
- (np .array ([0 , 1 , 2 ]), np .array ([5 , 4 , 3 ]), True ),
146
+ (np .array ([0 , 1 , 4 ], dtype = "int64" ), np .array ([2 , 3 , 5 ]), True ),
147
+ (np .array ([0 , 1 , 2 ], dtype = "int64" ), np .array ([5 , 4 , 3 ]), True ),
151
148
(np .array ([0 , 1 , np .nan ]), np .array ([5 , 4 , np .nan ]), True ),
152
- (np .array ([0 , 2 , 4 ]), np .array ([1 , 3 , 5 ]), False ),
149
+ (np .array ([0 , 2 , 4 ], dtype = "int64" ), np .array ([1 , 3 , 5 ]), False ),
153
150
(np .array ([0 , 2 , np .nan ]), np .array ([1 , 3 , np .nan ]), False ),
154
151
],
155
152
)
@@ -164,7 +161,7 @@ def test_is_overlapping(self, closed, order, left, right, expected):
164
161
def test_is_overlapping_endpoints (self , closed , order ):
165
162
"""shared endpoints are marked as overlapping"""
166
163
# GH 23309
167
- left , right = np .arange (3 ), np .arange (1 , 4 )
164
+ left , right = np .arange (3 , dtype = "int64" ), np .arange (1 , 4 )
168
165
tree = IntervalTree (left [order ], right [order ], closed = closed )
169
166
result = tree .is_overlapping
170
167
expected = closed == "both"
@@ -187,7 +184,7 @@ def test_is_overlapping_trivial(self, closed, left, right):
187
184
@pytest .mark .skipif (compat .is_platform_32bit (), reason = "GH 23440" )
188
185
def test_construction_overflow (self ):
189
186
# GH 25485
190
- left , right = np .arange (101 ), [np .iinfo (np .int64 ).max ] * 101
187
+ left , right = np .arange (101 , dtype = "int64" ), [np .iinfo (np .int64 ).max ] * 101
191
188
tree = IntervalTree (left , right )
192
189
193
190
# pivot should be average of left/right medians
0 commit comments