@@ -15,6 +15,7 @@ cnp.import_array()
15
15
16
16
cdef extern from " src/headers/cmath" namespace " std" :
17
17
bint isnan(double ) nogil
18
+ bint notnan(double ) nogil
18
19
int signbit(double ) nogil
19
20
double sqrt(double x) nogil
20
21
@@ -381,21 +382,21 @@ def roll_count(ndarray[double_t] input, int64_t win, int64_t minp,
381
382
count_x = 0.0
382
383
for j in range (s, e):
383
384
val = input [j]
384
- if not isnan (val):
385
+ if notnan (val):
385
386
count_x += 1.0
386
387
387
388
else :
388
389
389
390
# calculate deletes
390
391
for j in range (start[i - 1 ], s):
391
392
val = input [j]
392
- if not isnan (val):
393
+ if notnan (val):
393
394
count_x -= 1.0
394
395
395
396
# calculate adds
396
397
for j in range (end[i - 1 ], e):
397
398
val = input [j]
398
- if not isnan (val):
399
+ if notnan (val):
399
400
count_x += 1.0
400
401
401
402
if count_x >= minp:
@@ -424,15 +425,15 @@ cdef inline void add_sum(double val, int64_t *nobs, double *sum_x) nogil:
424
425
""" add a value from the sum calc """
425
426
426
427
# Not NaN
427
- if not isnan (val):
428
+ if notnan (val):
428
429
nobs[0 ] = nobs[0 ] + 1
429
430
sum_x[0 ] = sum_x[0 ] + val
430
431
431
432
432
433
cdef inline void remove_sum(double val, int64_t * nobs, double * sum_x) nogil:
433
434
""" remove a value from the sum calc """
434
435
435
- if not isnan (val):
436
+ if notnan (val):
436
437
nobs[0 ] = nobs[0 ] - 1
437
438
sum_x[0 ] = sum_x[0 ] - val
438
439
@@ -538,7 +539,7 @@ cdef inline void add_mean(double val, Py_ssize_t *nobs, double *sum_x,
538
539
""" add a value from the mean calc """
539
540
540
541
# Not NaN
541
- if not isnan (val):
542
+ if notnan (val):
542
543
nobs[0 ] = nobs[0 ] + 1
543
544
sum_x[0 ] = sum_x[0 ] + val
544
545
if signbit(val):
@@ -549,7 +550,7 @@ cdef inline void remove_mean(double val, Py_ssize_t *nobs, double *sum_x,
549
550
Py_ssize_t * neg_ct) nogil:
550
551
""" remove a value from the mean calc """
551
552
552
- if not isnan (val):
553
+ if notnan (val):
553
554
nobs[0 ] = nobs[0 ] - 1
554
555
sum_x[0 ] = sum_x[0 ] - val
555
556
if signbit(val):
@@ -671,7 +672,7 @@ cdef inline void remove_var(double val, double *nobs, double *mean_x,
671
672
""" remove a value from the var calc """
672
673
cdef double delta
673
674
674
- if not isnan (val):
675
+ if notnan (val):
675
676
nobs[0 ] = nobs[0 ] - 1
676
677
if nobs[0 ]:
677
678
# a part of Welford's method for the online variance-calculation
@@ -759,7 +760,7 @@ def roll_var(ndarray[double_t] input, int64_t win, int64_t minp,
759
760
val = input [i]
760
761
prev = input [i - win]
761
762
762
- if not isnan (val):
763
+ if notnan (val):
763
764
if prev == prev:
764
765
765
766
# Adding one observation and removing another one
@@ -821,7 +822,7 @@ cdef inline void add_skew(double val, int64_t *nobs, double *x, double *xx,
821
822
""" add a value from the skew calc """
822
823
823
824
# Not NaN
824
- if not isnan (val):
825
+ if notnan (val):
825
826
nobs[0 ] = nobs[0 ] + 1
826
827
827
828
# seriously don't ask me why this is faster
@@ -835,7 +836,7 @@ cdef inline void remove_skew(double val, int64_t *nobs, double *x, double *xx,
835
836
""" remove a value from the skew calc """
836
837
837
838
# Not NaN
838
- if not isnan (val):
839
+ if notnan (val):
839
840
nobs[0 ] = nobs[0 ] - 1
840
841
841
842
# seriously don't ask me why this is faster
@@ -958,7 +959,7 @@ cdef inline void add_kurt(double val, int64_t *nobs, double *x, double *xx,
958
959
""" add a value from the kurotic calc """
959
960
960
961
# Not NaN
961
- if not isnan (val):
962
+ if notnan (val):
962
963
nobs[0 ] = nobs[0 ] + 1
963
964
964
965
# seriously don't ask me why this is faster
@@ -973,7 +974,7 @@ cdef inline void remove_kurt(double val, int64_t *nobs, double *x, double *xx,
973
974
""" remove a value from the kurotic calc """
974
975
975
976
# Not NaN
976
- if not isnan (val):
977
+ if notnan (val):
977
978
nobs[0 ] = nobs[0 ] - 1
978
979
979
980
# seriously don't ask me why this is faster
@@ -1088,7 +1089,7 @@ def roll_median_c(ndarray[float64_t] input, int64_t win, int64_t minp,
1088
1089
1089
1090
# setup
1090
1091
val = input [i]
1091
- if not isnan (val):
1092
+ if notnan (val):
1092
1093
nobs += 1
1093
1094
err = skiplist_insert(sl, val) != 1
1094
1095
if err:
@@ -1099,14 +1100,14 @@ def roll_median_c(ndarray[float64_t] input, int64_t win, int64_t minp,
1099
1100
# calculate deletes
1100
1101
for j in range (start[i - 1 ], s):
1101
1102
val = input [j]
1102
- if not isnan (val):
1103
+ if notnan (val):
1103
1104
skiplist_remove(sl, val)
1104
1105
nobs -= 1
1105
1106
1106
1107
# calculate adds
1107
1108
for j in range (end[i - 1 ], e):
1108
1109
val = input [j]
1109
- if not isnan (val):
1110
+ if notnan (val):
1110
1111
nobs += 1
1111
1112
err = skiplist_insert(sl, val) != 1
1112
1113
if err:
@@ -1471,7 +1472,7 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,
1471
1472
1472
1473
# setup
1473
1474
val = input [i]
1474
- if not isnan (val):
1475
+ if notnan (val):
1475
1476
nobs += 1
1476
1477
skiplist_insert(skiplist, val)
1477
1478
@@ -1480,14 +1481,14 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,
1480
1481
# calculate deletes
1481
1482
for j in range (start[i - 1 ], s):
1482
1483
val = input [j]
1483
- if not isnan (val):
1484
+ if notnan (val):
1484
1485
skiplist_remove(skiplist, val)
1485
1486
nobs -= 1
1486
1487
1487
1488
# calculate adds
1488
1489
for j in range (end[i - 1 ], e):
1489
1490
val = input [j]
1490
- if not isnan (val):
1491
+ if notnan (val):
1491
1492
nobs += 1
1492
1493
skiplist_insert(skiplist, val)
1493
1494
0 commit comments