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