Skip to content

Commit 4cdccd7

Browse files
chris-b1victor
authored and
victor
committed
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 * ...
1 parent e561986 commit 4cdccd7

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
@@ -20,7 +20,7 @@ and bug fixes. We recommend that all users upgrade to this version.
2020
Fixed Regressions
2121
~~~~~~~~~~~~~~~~~
2222

23-
-
23+
- Python 3.7 with Windows gave all missing values for rolling variance calculations (:issue:`21813`)
2424
-
2525

2626
.. _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

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

667668

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

0 commit comments

Comments
 (0)