Skip to content

Commit 771aa07

Browse files
committed
use numpy isna function, remove unneeded lines
1 parent 8ba42bc commit 771aa07

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

pandas/_libs/groupby.pyx

+3-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ from numpy cimport (
2626
uint32_t,
2727
uint64_t,
2828
)
29-
from numpy.math cimport NAN
29+
from numpy.math cimport NAN, isinf
3030

3131
cnp.import_array()
3232

@@ -67,15 +67,6 @@ cdef enum InterpolationEnumType:
6767
INTERPOLATION_NEAREST,
6868
INTERPOLATION_MIDPOINT
6969

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-
7970
cdef inline float64_t median_linear(float64_t* a, int n) nogil:
8071
cdef:
8172
int i, j, na_count = 0
@@ -266,10 +257,10 @@ def group_cumsum(numeric_t[:, ::1] out,
266257

267258
# For floats, use Kahan summation to reduce floating-point
268259
# 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:
270261
if val == val:
271262
# 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]):
273264
accum[lab, j] += val
274265
out[i, j] = accum[lab, j]
275266
else:
@@ -576,7 +567,6 @@ def group_add(add_t[:, ::1] out,
576567
for j in range(K):
577568
val = values[i, j]
578569

579-
# function to release gil for the whole block
580570
if (val == MAXfloat64) or (val == MINfloat64):
581571
sumx[lab, j] = val
582572
break

0 commit comments

Comments
 (0)