Skip to content

Commit d432775

Browse files
chris-b1TomAugspurger
authored andcommitted
BUG: rolling with MSVC 2017 build (pandas-dev#21813)
* Appveyor 3.7 * ci package list * change image type * try hack fix * lint * use isnan on problem function * use numpy compat isnan * use right isnan * work around OSX math undefs * cleanup const * fix reversion * ... (cherry picked from commit 7a2fbce)
1 parent 6a0a950 commit d432775

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

appveyor.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ environment:
2020
matrix:
2121

2222
- CONDA_ROOT: "C:\\Miniconda3_64"
23+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
2324
PYTHON_VERSION: "3.6"
2425
PYTHON_ARCH: "64"
2526
CONDA_PY: "36"
2627
CONDA_NPY: "113"
2728

2829
- CONDA_ROOT: "C:\\Miniconda3_64"
30+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
2931
PYTHON_VERSION: "2.7"
3032
PYTHON_ARCH: "64"
3133
CONDA_PY: "27"

doc/source/whatsnew/v0.23.4.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ and bug fixes. We recommend that all users upgrade to this version.
1616
Fixed Regressions
1717
~~~~~~~~~~~~~~~~~
1818

19-
-
19+
- Python 3.7 with Windows gave all missing values for rolling variance calculations (:issue:`21813`)
2020
-
2121

2222
.. _whatsnew_0234.bug_fixes:

pandas/_libs/src/headers/cmath

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#if defined(_MSC_VER) && (_MSC_VER < 1800)
77
#include <cmath>
88
namespace std {
9+
__inline int isnan(double x) { return _isnan(x); }
910
__inline int signbit(double num) { return _copysign(1.0, num) < 0; }
1011
}
1112
#else

pandas/_libs/window.pyx

+11-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cnp.import_array()
1414

1515

1616
cdef extern from "../src/headers/cmath" namespace "std":
17+
bint isnan(double) nogil
1718
int signbit(double) nogil
1819
double sqrt(double x) nogil
1920

@@ -654,16 +655,16 @@ cdef inline void add_var(double val, double *nobs, double *mean_x,
654655
double *ssqdm_x) nogil:
655656
""" add a value from the var calc """
656657
cdef double delta
657-
658-
# Not NaN
659-
if val == val:
660-
nobs[0] = nobs[0] + 1
661-
662-
# a part of Welford's method for the online variance-calculation
663-
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
664-
delta = val - mean_x[0]
665-
mean_x[0] = mean_x[0] + delta / nobs[0]
666-
ssqdm_x[0] = ssqdm_x[0] + ((nobs[0] - 1) * delta ** 2) / nobs[0]
658+
# `isnan` instead of equality as fix for GH-21813, msvc 2017 bug
659+
if isnan(val):
660+
return
661+
662+
nobs[0] = nobs[0] + 1
663+
# a part of Welford's method for the online variance-calculation
664+
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
665+
delta = val - mean_x[0]
666+
mean_x[0] = mean_x[0] + delta / nobs[0]
667+
ssqdm_x[0] = ssqdm_x[0] + ((nobs[0] - 1) * delta ** 2) / nobs[0]
667668

668669

669670
cdef inline void remove_var(double val, double *nobs, double *mean_x,

0 commit comments

Comments
 (0)