@@ -15,6 +15,7 @@ cnp.import_array()
1515
1616cdef extern from " src/headers/cmath" namespace " std" :
1717 bint isnan(double ) nogil
18+ bint notnan(double ) nogil
1819 int signbit(double ) nogil
1920 double sqrt(double x) nogil
2021
@@ -381,21 +382,21 @@ def roll_count(ndarray[double_t] input, int64_t win, int64_t minp,
381382 count_x = 0.0
382383 for j in range (s, e):
383384 val = input [j]
384- if not isnan (val):
385+ if notnan (val):
385386 count_x += 1.0
386387
387388 else :
388389
389390 # calculate deletes
390391 for j in range (start[i - 1 ], s):
391392 val = input [j]
392- if not isnan (val):
393+ if notnan (val):
393394 count_x -= 1.0
394395
395396 # calculate adds
396397 for j in range (end[i - 1 ], e):
397398 val = input [j]
398- if not isnan (val):
399+ if notnan (val):
399400 count_x += 1.0
400401
401402 if count_x >= minp:
@@ -424,15 +425,15 @@ cdef inline void add_sum(double val, int64_t *nobs, double *sum_x) nogil:
424425 """ add a value from the sum calc """
425426
426427 # Not NaN
427- if not isnan (val):
428+ if notnan (val):
428429 nobs[0 ] = nobs[0 ] + 1
429430 sum_x[0 ] = sum_x[0 ] + val
430431
431432
432433cdef inline void remove_sum(double val, int64_t * nobs, double * sum_x) nogil:
433434 """ remove a value from the sum calc """
434435
435- if not isnan (val):
436+ if notnan (val):
436437 nobs[0 ] = nobs[0 ] - 1
437438 sum_x[0 ] = sum_x[0 ] - val
438439
@@ -538,7 +539,7 @@ cdef inline void add_mean(double val, Py_ssize_t *nobs, double *sum_x,
538539 """ add a value from the mean calc """
539540
540541 # Not NaN
541- if not isnan (val):
542+ if notnan (val):
542543 nobs[0 ] = nobs[0 ] + 1
543544 sum_x[0 ] = sum_x[0 ] + val
544545 if signbit(val):
@@ -549,7 +550,7 @@ cdef inline void remove_mean(double val, Py_ssize_t *nobs, double *sum_x,
549550 Py_ssize_t * neg_ct) nogil:
550551 """ remove a value from the mean calc """
551552
552- if not isnan (val):
553+ if notnan (val):
553554 nobs[0 ] = nobs[0 ] - 1
554555 sum_x[0 ] = sum_x[0 ] - val
555556 if signbit(val):
@@ -671,7 +672,7 @@ cdef inline void remove_var(double val, double *nobs, double *mean_x,
671672 """ remove a value from the var calc """
672673 cdef double delta
673674
674- if not isnan (val):
675+ if notnan (val):
675676 nobs[0 ] = nobs[0 ] - 1
676677 if nobs[0 ]:
677678 # 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,
759760 val = input [i]
760761 prev = input [i - win]
761762
762- if not isnan (val):
763+ if notnan (val):
763764 if prev == prev:
764765
765766 # 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,
821822 """ add a value from the skew calc """
822823
823824 # Not NaN
824- if not isnan (val):
825+ if notnan (val):
825826 nobs[0 ] = nobs[0 ] + 1
826827
827828 # 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,
835836 """ remove a value from the skew calc """
836837
837838 # Not NaN
838- if not isnan (val):
839+ if notnan (val):
839840 nobs[0 ] = nobs[0 ] - 1
840841
841842 # 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,
958959 """ add a value from the kurotic calc """
959960
960961 # Not NaN
961- if not isnan (val):
962+ if notnan (val):
962963 nobs[0 ] = nobs[0 ] + 1
963964
964965 # 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,
973974 """ remove a value from the kurotic calc """
974975
975976 # Not NaN
976- if not isnan (val):
977+ if notnan (val):
977978 nobs[0 ] = nobs[0 ] - 1
978979
979980 # 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,
10881089
10891090 # setup
10901091 val = input [i]
1091- if not isnan (val):
1092+ if notnan (val):
10921093 nobs += 1
10931094 err = skiplist_insert(sl, val) != 1
10941095 if err:
@@ -1099,14 +1100,14 @@ def roll_median_c(ndarray[float64_t] input, int64_t win, int64_t minp,
10991100 # calculate deletes
11001101 for j in range (start[i - 1 ], s):
11011102 val = input [j]
1102- if not isnan (val):
1103+ if notnan (val):
11031104 skiplist_remove(sl, val)
11041105 nobs -= 1
11051106
11061107 # calculate adds
11071108 for j in range (end[i - 1 ], e):
11081109 val = input [j]
1109- if not isnan (val):
1110+ if notnan (val):
11101111 nobs += 1
11111112 err = skiplist_insert(sl, val) != 1
11121113 if err:
@@ -1471,7 +1472,7 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,
14711472
14721473 # setup
14731474 val = input [i]
1474- if not isnan (val):
1475+ if notnan (val):
14751476 nobs += 1
14761477 skiplist_insert(skiplist, val)
14771478
@@ -1480,14 +1481,14 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,
14801481 # calculate deletes
14811482 for j in range (start[i - 1 ], s):
14821483 val = input [j]
1483- if not isnan (val):
1484+ if notnan (val):
14841485 skiplist_remove(skiplist, val)
14851486 nobs -= 1
14861487
14871488 # calculate adds
14881489 for j in range (end[i - 1 ], e):
14891490 val = input [j]
1490- if not isnan (val):
1491+ if notnan (val):
14911492 nobs += 1
14921493 skiplist_insert(skiplist, val)
14931494
0 commit comments