@@ -6,12 +6,20 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
6
6
7
7
from pandas._libs.algos import is_monotonic
8
8
9
- ctypedef fused scalar_t:
10
- float64_t
11
- float32_t
9
+ ctypedef fused int_scalar_t:
12
10
int64_t
13
11
int32_t
12
+ float64_t
13
+ float32_t
14
+
15
+ ctypedef fused uint_scalar_t:
14
16
uint64_t
17
+ float64_t
18
+ float32_t
19
+
20
+ ctypedef fused scalar_t:
21
+ int_scalar_t
22
+ uint_scalar_t
15
23
16
24
# ----------------------------------------------------------------------
17
25
# IntervalTree
@@ -128,7 +136,12 @@ cdef class IntervalTree(IntervalMixin):
128
136
result = Int64Vector()
129
137
old_len = 0
130
138
for i in range(len(target)):
131
- self.root.query(result, target[i])
139
+ try:
140
+ self.root.query(result, target[i])
141
+ except OverflowError:
142
+ # overflow -> no match, which is already handled below
143
+ pass
144
+
132
145
if result.data.n == old_len:
133
146
result.append(-1)
134
147
elif result.data.n > old_len + 1:
@@ -150,7 +163,12 @@ cdef class IntervalTree(IntervalMixin):
150
163
missing = Int64Vector()
151
164
old_len = 0
152
165
for i in range(len(target)):
153
- self.root.query(result, target[i])
166
+ try:
167
+ self.root.query(result, target[i])
168
+ except OverflowError:
169
+ # overflow -> no match, which is already handled below
170
+ pass
171
+
154
172
if result.data.n == old_len:
155
173
result.append(-1)
156
174
missing.append(i)
@@ -202,19 +220,26 @@ for dtype in ['float32', 'float64', 'int32', 'int64', 'uint64']:
202
220
('neither', '<', '<')]:
203
221
cmp_left_converse = '<' if cmp_left == '<=' else '<='
204
222
cmp_right_converse = '<' if cmp_right == '<=' else '<='
223
+ if dtype.startswith('int'):
224
+ fused_prefix = 'int_'
225
+ elif dtype.startswith('uint'):
226
+ fused_prefix = 'uint_'
227
+ elif dtype.startswith('float'):
228
+ fused_prefix = ''
205
229
nodes.append((dtype, dtype.title(),
206
230
closed, closed.title(),
207
231
cmp_left,
208
232
cmp_right,
209
233
cmp_left_converse,
210
- cmp_right_converse))
234
+ cmp_right_converse,
235
+ fused_prefix))
211
236
212
237
}}
213
238
214
239
NODE_CLASSES = {}
215
240
216
241
{{for dtype, dtype_title, closed, closed_title, cmp_left, cmp_right,
217
- cmp_left_converse, cmp_right_converse in nodes}}
242
+ cmp_left_converse, cmp_right_converse, fused_prefix in nodes}}
218
243
219
244
cdef class {{dtype_title}}Closed{{closed_title}}IntervalNode:
220
245
"""Non-terminal node for an IntervalTree
@@ -317,7 +342,7 @@ cdef class {{dtype_title}}Closed{{closed_title}}IntervalNode:
317
342
@cython.wraparound(False)
318
343
@cython.boundscheck(False)
319
344
@cython.initializedcheck(False)
320
- cpdef query(self, Int64Vector result, scalar_t point):
345
+ cpdef query(self, Int64Vector result, {{fused_prefix}} scalar_t point):
321
346
"""Recursively query this node and its sub-nodes for intervals that
322
347
overlap with the query point.
323
348
"""
0 commit comments