@@ -26,7 +26,7 @@ from numpy cimport (
26
26
uint32_t,
27
27
uint64_t,
28
28
)
29
- from numpy.math cimport NAN
29
+ from numpy.math cimport NAN, isinf
30
30
31
31
cnp.import_array()
32
32
@@ -67,15 +67,6 @@ cdef enum InterpolationEnumType:
67
67
INTERPOLATION_NEAREST,
68
68
INTERPOLATION_MIDPOINT
69
69
70
- cdef inline bint check_inf(numeric_t ai) nogil:
71
-
72
- if numeric_t == cython.float:
73
- if (ai == MINfloat32) or (ai == MAXfloat32):
74
- return True
75
- else :
76
- if (ai == MINfloat64) or (ai == MAXfloat64):
77
- return True
78
-
79
70
cdef inline float64_t median_linear(float64_t* a, int n) nogil:
80
71
cdef:
81
72
int i, j, na_count = 0
@@ -266,10 +257,10 @@ def group_cumsum(numeric_t[:, ::1] out,
266
257
267
258
# For floats, use Kahan summation to reduce floating-point
268
259
# error (https://en.wikipedia.org/wiki/Kahan_summation_algorithm)
269
- if ( numeric_t == float32_t) or ( numeric_t == float64_t) :
260
+ if numeric_t is float32_t or numeric_t is float64_t:
270
261
if val == val:
271
262
# if val or accum are inf/-inf don't use kahan
272
- if check_inf (val) or check_inf (accum[lab, j]):
263
+ if isinf (val) or isinf (accum[lab, j]):
273
264
accum[lab, j] += val
274
265
out[i, j] = accum[lab, j]
275
266
else :
@@ -576,7 +567,6 @@ def group_add(add_t[:, ::1] out,
576
567
for j in range (K):
577
568
val = values[i, j]
578
569
579
- # function to release gil for the whole block
580
570
if (val == MAXfloat64) or (val == MINfloat64):
581
571
sumx[lab, j] = val
582
572
break
0 commit comments