Skip to content

BUG: rolling with MSVC 2017 build #21813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ environment:
matrix:

- CONDA_ROOT: "C:\\Miniconda3_64"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
CONDA_PY: "36"
CONDA_NPY: "113"

- CONDA_ROOT: "C:\\Miniconda3_64"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "64"
CONDA_PY: "27"
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.23.4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and bug fixes. We recommend that all users upgrade to this version.
Fixed Regressions
~~~~~~~~~~~~~~~~~

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

.. _whatsnew_0234.bug_fixes:
Expand Down
1 change: 1 addition & 0 deletions pandas/_libs/src/headers/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#if defined(_MSC_VER) && (_MSC_VER < 1800)
#include <cmath>
namespace std {
__inline int isnan(double x) { return _isnan(x); }
__inline int signbit(double num) { return _copysign(1.0, num) < 0; }
}
#else
Expand Down
21 changes: 11 additions & 10 deletions pandas/_libs/window.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cnp.import_array()


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

Expand Down Expand Up @@ -653,16 +654,16 @@ cdef inline void add_var(double val, double *nobs, double *mean_x,
double *ssqdm_x) nogil:
""" add a value from the var calc """
cdef double delta

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing

if val != val:
    return

# rest of code

might work (and be more clear here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, sadly didn't work

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

# a part of Welford's method for the online variance-calculation
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
delta = val - mean_x[0]
mean_x[0] = mean_x[0] + delta / nobs[0]
ssqdm_x[0] = ssqdm_x[0] + ((nobs[0] - 1) * delta ** 2) / nobs[0]
# `isnan` instead of equality as fix for GH-21813, msvc 2017 bug
if isnan(val):
return

nobs[0] = nobs[0] + 1
# a part of Welford's method for the online variance-calculation
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
delta = val - mean_x[0]
mean_x[0] = mean_x[0] + delta / nobs[0]
ssqdm_x[0] = ssqdm_x[0] + ((nobs[0] - 1) * delta ** 2) / nobs[0]


cdef inline void remove_var(double val, double *nobs, double *mean_x,
Expand Down