Skip to content

Commit

Permalink
Windows CI (pandas-dev#23182)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger authored Oct 18, 2018
1 parent 9285820 commit 1546c35
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
2 changes: 2 additions & 0 deletions ci/azure-windows-36.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ channels:
dependencies:
- blosc
- bottleneck
- boost-cpp<1.67
- fastparquet
- feather-format
- matplotlib
- numexpr
- numpy=1.14*
- openpyxl=2.5.5
- parquet-cpp
- pyarrow
- pytables
- python-dateutil
Expand Down
26 changes: 23 additions & 3 deletions pandas/_libs/src/headers/cmath
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
#ifndef _PANDAS_MATH_H_
#define _PANDAS_MATH_H_

// MSVC 2017 has a bug where `x == x` can be true for NaNs.
// MSC_VER from https://stackoverflow.com/a/70630/1889400
// Place upper bound on this check once a fixed MSVC is released.
#if defined(_MSC_VER) && (_MSC_VER < 1800)
#include <cmath>
// In older versions of Visual Studio there wasn't a std::signbit defined
// This defines it using _copysign
#if defined(_MSC_VER) && (_MSC_VER < 1800)
namespace std {
__inline int isnan(double x) { return _isnan(x); }
__inline int signbit(double num) { return _copysign(1.0, num) < 0; }
__inline int notnan(double x) { return !isnan(x); }
}
#elif defined(_MSC_VER) && (_MSC_VER >= 1900)
#include <cmath>
namespace std {
__inline int isnan(double x) { return _isnan(x); }
__inline int notnan(double x) { return !isnan(x); }
}
#elif defined(_MSC_VER)
#include <cmath>
namespace std {
__inline int isnan(double x) { return _isnan(x); }
__inline int signbit(double num) { return _copysign(1.0, num) < 0; }
__inline int notnan(double x) { return x == x; }
}
#else
#include <cmath>
#endif

namespace std {
__inline int notnan(double x) { return x == x; }
}

#endif
#endif
40 changes: 20 additions & 20 deletions pandas/_libs/window.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cnp.import_array()

cdef extern from "src/headers/cmath" namespace "std":
bint isnan(double) nogil
bint notnan(double) nogil
int signbit(double) nogil
double sqrt(double x) nogil

Expand Down Expand Up @@ -381,21 +382,21 @@ def roll_count(ndarray[double_t] input, int64_t win, int64_t minp,
count_x = 0.0
for j in range(s, e):
val = input[j]
if val == val:
if notnan(val):
count_x += 1.0

else:

# calculate deletes
for j in range(start[i - 1], s):
val = input[j]
if val == val:
if notnan(val):
count_x -= 1.0

# calculate adds
for j in range(end[i - 1], e):
val = input[j]
if val == val:
if notnan(val):
count_x += 1.0

if count_x >= minp:
Expand Down Expand Up @@ -424,15 +425,15 @@ cdef inline void add_sum(double val, int64_t *nobs, double *sum_x) nogil:
""" add a value from the sum calc """

# Not NaN
if val == val:
if notnan(val):
nobs[0] = nobs[0] + 1
sum_x[0] = sum_x[0] + val


cdef inline void remove_sum(double val, int64_t *nobs, double *sum_x) nogil:
""" remove a value from the sum calc """

if val == val:
if notnan(val):
nobs[0] = nobs[0] - 1
sum_x[0] = sum_x[0] - val

Expand Down Expand Up @@ -538,7 +539,7 @@ cdef inline void add_mean(double val, Py_ssize_t *nobs, double *sum_x,
""" add a value from the mean calc """

# Not NaN
if val == val:
if notnan(val):
nobs[0] = nobs[0] + 1
sum_x[0] = sum_x[0] + val
if signbit(val):
Expand All @@ -549,7 +550,7 @@ cdef inline void remove_mean(double val, Py_ssize_t *nobs, double *sum_x,
Py_ssize_t *neg_ct) nogil:
""" remove a value from the mean calc """

if val == val:
if notnan(val):
nobs[0] = nobs[0] - 1
sum_x[0] = sum_x[0] - val
if signbit(val):
Expand Down Expand Up @@ -671,8 +672,7 @@ cdef inline void remove_var(double val, double *nobs, double *mean_x,
""" remove a value from the var calc """
cdef double delta

# Not NaN
if val == val:
if notnan(val):
nobs[0] = nobs[0] - 1
if nobs[0]:
# a part of Welford's method for the online variance-calculation
Expand Down Expand Up @@ -760,7 +760,7 @@ def roll_var(ndarray[double_t] input, int64_t win, int64_t minp,
val = input[i]
prev = input[i - win]

if val == val:
if notnan(val):
if prev == prev:

# Adding one observation and removing another one
Expand Down Expand Up @@ -822,7 +822,7 @@ cdef inline void add_skew(double val, int64_t *nobs, double *x, double *xx,
""" add a value from the skew calc """

# Not NaN
if val == val:
if notnan(val):
nobs[0] = nobs[0] + 1

# seriously don't ask me why this is faster
Expand All @@ -836,7 +836,7 @@ cdef inline void remove_skew(double val, int64_t *nobs, double *x, double *xx,
""" remove a value from the skew calc """

# Not NaN
if val == val:
if notnan(val):
nobs[0] = nobs[0] - 1

# seriously don't ask me why this is faster
Expand Down Expand Up @@ -959,7 +959,7 @@ cdef inline void add_kurt(double val, int64_t *nobs, double *x, double *xx,
""" add a value from the kurotic calc """

# Not NaN
if val == val:
if notnan(val):
nobs[0] = nobs[0] + 1

# seriously don't ask me why this is faster
Expand All @@ -974,7 +974,7 @@ cdef inline void remove_kurt(double val, int64_t *nobs, double *x, double *xx,
""" remove a value from the kurotic calc """

# Not NaN
if val == val:
if notnan(val):
nobs[0] = nobs[0] - 1

# seriously don't ask me why this is faster
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def roll_median_c(ndarray[float64_t] input, int64_t win, int64_t minp,

# setup
val = input[i]
if val == val:
if notnan(val):
nobs += 1
err = skiplist_insert(sl, val) != 1
if err:
Expand All @@ -1100,14 +1100,14 @@ def roll_median_c(ndarray[float64_t] input, int64_t win, int64_t minp,
# calculate deletes
for j in range(start[i - 1], s):
val = input[j]
if val == val:
if notnan(val):
skiplist_remove(sl, val)
nobs -= 1

# calculate adds
for j in range(end[i - 1], e):
val = input[j]
if val == val:
if notnan(val):
nobs += 1
err = skiplist_insert(sl, val) != 1
if err:
Expand Down Expand Up @@ -1472,7 +1472,7 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,

# setup
val = input[i]
if val == val:
if notnan(val):
nobs += 1
skiplist_insert(skiplist, val)

Expand All @@ -1481,14 +1481,14 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,
# calculate deletes
for j in range(start[i - 1], s):
val = input[j]
if val == val:
if notnan(val):
skiplist_remove(skiplist, val)
nobs -= 1

# calculate adds
for j in range(end[i - 1], e):
val = input[j]
if val == val:
if notnan(val):
nobs += 1
skiplist_insert(skiplist, val)

Expand Down

0 comments on commit 1546c35

Please sign in to comment.