Skip to content

BLD: remove MSVC workaround #45008

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 1 commit into from
Jan 30, 2022
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
48 changes: 0 additions & 48 deletions pandas/_libs/src/headers/cmath

This file was deleted.

64 changes: 31 additions & 33 deletions pandas/_libs/window/aggregations.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import cython

from libc.math cimport round
from libc.math cimport (
round,
signbit,
sqrt,
)
from libcpp.deque cimport deque

from pandas._libs.algos cimport TiebreakEnumType
Expand All @@ -19,14 +23,8 @@ from numpy cimport (

cnp.import_array()


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

from pandas._libs.algos import is_monotonic

from pandas._libs.dtypes cimport numeric_t


Expand Down Expand Up @@ -94,7 +92,7 @@ cdef inline void add_sum(float64_t val, int64_t *nobs, float64_t *sum_x,
float64_t y, t

# Not NaN
if notnan(val):
if val == val:
nobs[0] = nobs[0] + 1
y = val - compensation[0]
t = sum_x[0] + y
Expand All @@ -110,7 +108,7 @@ cdef inline void remove_sum(float64_t val, int64_t *nobs, float64_t *sum_x,
float64_t y, t

# Not NaN
if notnan(val):
if val == val:
nobs[0] = nobs[0] - 1
y = - val - compensation[0]
t = sum_x[0] + y
Expand Down Expand Up @@ -197,7 +195,7 @@ cdef inline void add_mean(float64_t val, Py_ssize_t *nobs, float64_t *sum_x,
float64_t y, t

# Not NaN
if notnan(val):
if val == val:
nobs[0] = nobs[0] + 1
y = val - compensation[0]
t = sum_x[0] + y
Expand All @@ -213,7 +211,7 @@ cdef inline void remove_mean(float64_t val, Py_ssize_t *nobs, float64_t *sum_x,
cdef:
float64_t y, t

if notnan(val):
if val == val:
nobs[0] = nobs[0] - 1
y = - val - compensation[0]
t = sum_x[0] + y
Expand Down Expand Up @@ -300,8 +298,8 @@ cdef inline void add_var(float64_t val, float64_t *nobs, float64_t *mean_x,
cdef:
float64_t delta, prev_mean, y, t

# `isnan` instead of equality as fix for GH-21813, msvc 2017 bug
if isnan(val):
# GH#21813, if msvc 2017 bug is resolved, we should be OK with != instead of `isnan`
if val != val:
return

nobs[0] = nobs[0] + 1
Expand All @@ -325,7 +323,7 @@ cdef inline void remove_var(float64_t val, float64_t *nobs, float64_t *mean_x,
""" remove a value from the var calc """
cdef:
float64_t delta, prev_mean, y, t
if notnan(val):
if val == val:
nobs[0] = nobs[0] - 1
if nobs[0]:
# Welford's method for the online variance-calculation
Expand Down Expand Up @@ -450,7 +448,7 @@ cdef inline void add_skew(float64_t val, int64_t *nobs,
float64_t y, t

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

y = val - compensation_x[0]
Expand Down Expand Up @@ -478,7 +476,7 @@ cdef inline void remove_skew(float64_t val, int64_t *nobs,
float64_t y, t

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

y = - val - compensation_x[0]
Expand Down Expand Up @@ -520,7 +518,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
with nogil:
for i in range(0, N):
val = values_copy[i]
if notnan(val):
if val == val:
nobs_mean += 1
sum_val += val
mean_val = sum_val / nobs_mean
Expand Down Expand Up @@ -623,7 +621,7 @@ cdef inline void add_kurt(float64_t val, int64_t *nobs,
float64_t y, t

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

y = val - compensation_x[0]
Expand Down Expand Up @@ -656,7 +654,7 @@ cdef inline void remove_kurt(float64_t val, int64_t *nobs,
float64_t y, t

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

y = - val - compensation_x[0]
Expand Down Expand Up @@ -702,7 +700,7 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
with nogil:
for i in range(0, N):
val = values_copy[i]
if notnan(val):
if val == val:
nobs_mean += 1
sum_val += val
mean_val = sum_val / nobs_mean
Expand Down Expand Up @@ -796,7 +794,7 @@ def roll_median_c(const float64_t[:] values, ndarray[int64_t] start,
# setup
for j in range(s, e):
val = values[j]
if notnan(val):
if val == val:
nobs += 1
err = skiplist_insert(sl, val) == -1
if err:
Expand All @@ -807,7 +805,7 @@ def roll_median_c(const float64_t[:] values, ndarray[int64_t] start,
# calculate adds
for j in range(end[i - 1], e):
val = values[j]
if notnan(val):
if val == val:
nobs += 1
err = skiplist_insert(sl, val) == -1
if err:
Expand All @@ -816,7 +814,7 @@ def roll_median_c(const float64_t[:] values, ndarray[int64_t] start,
# calculate deletes
for j in range(start[i - 1], s):
val = values[j]
if notnan(val):
if val == val:
skiplist_remove(sl, val)
nobs -= 1
if nobs >= minp:
Expand Down Expand Up @@ -1077,22 +1075,22 @@ def roll_quantile(const float64_t[:] values, ndarray[int64_t] start,
# setup
for j in range(s, e):
val = values[j]
if notnan(val):
if val == val:
nobs += 1
skiplist_insert(skiplist, val)

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

# calculate deletes
for j in range(start[i - 1], s):
val = values[j]
if notnan(val):
if val == val:
skiplist_remove(skiplist, val)
nobs -= 1
if nobs >= minp:
Expand Down Expand Up @@ -1202,7 +1200,7 @@ def roll_rank(const float64_t[:] values, ndarray[int64_t] start,
# setup
for j in range(s, e):
val = values[j] if ascending else -values[j]
if notnan(val):
if val == val:
nobs += 1
rank = skiplist_insert(skiplist, val)
if rank == -1:
Expand All @@ -1229,14 +1227,14 @@ def roll_rank(const float64_t[:] values, ndarray[int64_t] start,
# calculate deletes
for j in range(start[i - 1], s):
val = values[j] if ascending else -values[j]
if notnan(val):
if val == val:
skiplist_remove(skiplist, val)
nobs -= 1

# calculate adds
for j in range(end[i - 1], e):
val = values[j] if ascending else -values[j]
if notnan(val):
if val == val:
nobs += 1
rank = skiplist_insert(skiplist, val)
if rank == -1:
Expand Down Expand Up @@ -1472,7 +1470,7 @@ cdef inline void add_weighted_var(float64_t val,
cdef:
float64_t temp, q, r

if isnan(val):
if val != val:
return

nobs[0] = nobs[0] + 1
Expand Down Expand Up @@ -1518,7 +1516,7 @@ cdef inline void remove_weighted_var(float64_t val,
cdef:
float64_t temp, q, r

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

if nobs[0]:
Expand Down Expand Up @@ -1588,7 +1586,7 @@ def roll_weighted_var(const float64_t[:] values, const float64_t[:] weights,
w = weights[i % win_n]
pre_w = weights[(i - win_n) % win_n]

if notnan(val):
if val == val:
if pre_val == pre_val:
remove_weighted_var(pre_val, pre_w, &t,
&sum_w, &mean, &nobs)
Expand Down