Skip to content

Commit f77480f

Browse files
authored
BLD: remove msvc workaround (#45008)
1 parent 4d21758 commit f77480f

File tree

2 files changed

+31
-81
lines changed

2 files changed

+31
-81
lines changed

Diff for: pandas/_libs/src/headers/cmath

-48
This file was deleted.

Diff for: pandas/_libs/window/aggregations.pyx

+31-33
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import cython
44

5-
from libc.math cimport round
5+
from libc.math cimport (
6+
round,
7+
signbit,
8+
sqrt,
9+
)
610
from libcpp.deque cimport deque
711

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

2024
cnp.import_array()
2125

22-
23-
cdef extern from "../src/headers/cmath" namespace "std":
24-
bint isnan(float64_t) nogil
25-
bint notnan(float64_t) nogil
26-
int signbit(float64_t) nogil
27-
float64_t sqrt(float64_t x) nogil
28-
2926
from pandas._libs.algos import is_monotonic
27+
3028
from pandas._libs.dtypes cimport numeric_t
3129

3230

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

9694
# Not NaN
97-
if notnan(val):
95+
if val == val:
9896
nobs[0] = nobs[0] + 1
9997
y = val - compensation[0]
10098
t = sum_x[0] + y
@@ -110,7 +108,7 @@ cdef inline void remove_sum(float64_t val, int64_t *nobs, float64_t *sum_x,
110108
float64_t y, t
111109

112110
# Not NaN
113-
if notnan(val):
111+
if val == val:
114112
nobs[0] = nobs[0] - 1
115113
y = - val - compensation[0]
116114
t = sum_x[0] + y
@@ -199,7 +197,7 @@ cdef inline void add_mean(float64_t val, Py_ssize_t *nobs, float64_t *sum_x,
199197
float64_t y, t
200198

201199
# Not NaN
202-
if notnan(val):
200+
if val == val:
203201
nobs[0] = nobs[0] + 1
204202
y = val - compensation[0]
205203
t = sum_x[0] + y
@@ -215,7 +213,7 @@ cdef inline void remove_mean(float64_t val, Py_ssize_t *nobs, float64_t *sum_x,
215213
cdef:
216214
float64_t y, t
217215

218-
if notnan(val):
216+
if val == val:
219217
nobs[0] = nobs[0] - 1
220218
y = - val - compensation[0]
221219
t = sum_x[0] + y
@@ -304,8 +302,8 @@ cdef inline void add_var(float64_t val, float64_t *nobs, float64_t *mean_x,
304302
cdef:
305303
float64_t delta, prev_mean, y, t
306304

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

311309
nobs[0] = nobs[0] + 1
@@ -329,7 +327,7 @@ cdef inline void remove_var(float64_t val, float64_t *nobs, float64_t *mean_x,
329327
""" remove a value from the var calc """
330328
cdef:
331329
float64_t delta, prev_mean, y, t
332-
if notnan(val):
330+
if val == val:
333331
nobs[0] = nobs[0] - 1
334332
if nobs[0]:
335333
# Welford's method for the online variance-calculation
@@ -455,7 +453,7 @@ cdef inline void add_skew(float64_t val, int64_t *nobs,
455453
float64_t y, t
456454

457455
# Not NaN
458-
if notnan(val):
456+
if val == val:
459457
nobs[0] = nobs[0] + 1
460458

461459
y = val - compensation_x[0]
@@ -483,7 +481,7 @@ cdef inline void remove_skew(float64_t val, int64_t *nobs,
483481
float64_t y, t
484482

485483
# Not NaN
486-
if notnan(val):
484+
if val == val:
487485
nobs[0] = nobs[0] - 1
488486

489487
y = - val - compensation_x[0]
@@ -525,7 +523,7 @@ def roll_skew(ndarray[float64_t] values, ndarray[int64_t] start,
525523
with nogil:
526524
for i in range(0, V):
527525
val = values_copy[i]
528-
if notnan(val):
526+
if val == val:
529527
nobs_mean += 1
530528
sum_val += val
531529
mean_val = sum_val / nobs_mean
@@ -633,7 +631,7 @@ cdef inline void add_kurt(float64_t val, int64_t *nobs,
633631
float64_t y, t
634632

635633
# Not NaN
636-
if notnan(val):
634+
if val == val:
637635
nobs[0] = nobs[0] + 1
638636

639637
y = val - compensation_x[0]
@@ -666,7 +664,7 @@ cdef inline void remove_kurt(float64_t val, int64_t *nobs,
666664
float64_t y, t
667665

668666
# Not NaN
669-
if notnan(val):
667+
if val == val:
670668
nobs[0] = nobs[0] - 1
671669

672670
y = - val - compensation_x[0]
@@ -712,7 +710,7 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
712710
with nogil:
713711
for i in range(0, V):
714712
val = values_copy[i]
715-
if notnan(val):
713+
if val == val:
716714
nobs_mean += 1
717715
sum_val += val
718716
mean_val = sum_val / nobs_mean
@@ -816,7 +814,7 @@ def roll_median_c(const float64_t[:] values, ndarray[int64_t] start,
816814
# setup
817815
for j in range(s, e):
818816
val = values[j]
819-
if notnan(val):
817+
if val == val:
820818
nobs += 1
821819
err = skiplist_insert(sl, val) == -1
822820
if err:
@@ -827,7 +825,7 @@ def roll_median_c(const float64_t[:] values, ndarray[int64_t] start,
827825
# calculate adds
828826
for j in range(end[i - 1], e):
829827
val = values[j]
830-
if notnan(val):
828+
if val == val:
831829
nobs += 1
832830
err = skiplist_insert(sl, val) == -1
833831
if err:
@@ -836,7 +834,7 @@ def roll_median_c(const float64_t[:] values, ndarray[int64_t] start,
836834
# calculate deletes
837835
for j in range(start[i - 1], s):
838836
val = values[j]
839-
if notnan(val):
837+
if val == val:
840838
skiplist_remove(sl, val)
841839
nobs -= 1
842840
if nobs >= minp:
@@ -1097,22 +1095,22 @@ def roll_quantile(const float64_t[:] values, ndarray[int64_t] start,
10971095
# setup
10981096
for j in range(s, e):
10991097
val = values[j]
1100-
if notnan(val):
1098+
if val == val:
11011099
nobs += 1
11021100
skiplist_insert(skiplist, val)
11031101

11041102
else:
11051103
# calculate adds
11061104
for j in range(end[i - 1], e):
11071105
val = values[j]
1108-
if notnan(val):
1106+
if val == val:
11091107
nobs += 1
11101108
skiplist_insert(skiplist, val)
11111109

11121110
# calculate deletes
11131111
for j in range(start[i - 1], s):
11141112
val = values[j]
1115-
if notnan(val):
1113+
if val == val:
11161114
skiplist_remove(skiplist, val)
11171115
nobs -= 1
11181116
if nobs >= minp:
@@ -1222,7 +1220,7 @@ def roll_rank(const float64_t[:] values, ndarray[int64_t] start,
12221220
# setup
12231221
for j in range(s, e):
12241222
val = values[j] if ascending else -values[j]
1225-
if notnan(val):
1223+
if val == val:
12261224
nobs += 1
12271225
rank = skiplist_insert(skiplist, val)
12281226
if rank == -1:
@@ -1249,14 +1247,14 @@ def roll_rank(const float64_t[:] values, ndarray[int64_t] start,
12491247
# calculate deletes
12501248
for j in range(start[i - 1], s):
12511249
val = values[j] if ascending else -values[j]
1252-
if notnan(val):
1250+
if val == val:
12531251
skiplist_remove(skiplist, val)
12541252
nobs -= 1
12551253

12561254
# calculate adds
12571255
for j in range(end[i - 1], e):
12581256
val = values[j] if ascending else -values[j]
1259-
if notnan(val):
1257+
if val == val:
12601258
nobs += 1
12611259
rank = skiplist_insert(skiplist, val)
12621260
if rank == -1:
@@ -1492,7 +1490,7 @@ cdef inline void add_weighted_var(float64_t val,
14921490
cdef:
14931491
float64_t temp, q, r
14941492

1495-
if isnan(val):
1493+
if val != val:
14961494
return
14971495

14981496
nobs[0] = nobs[0] + 1
@@ -1538,7 +1536,7 @@ cdef inline void remove_weighted_var(float64_t val,
15381536
cdef:
15391537
float64_t temp, q, r
15401538

1541-
if notnan(val):
1539+
if val == val:
15421540
nobs[0] = nobs[0] - 1
15431541

15441542
if nobs[0]:
@@ -1608,7 +1606,7 @@ def roll_weighted_var(const float64_t[:] values, const float64_t[:] weights,
16081606
w = weights[i % win_n]
16091607
pre_w = weights[(i - win_n) % win_n]
16101608

1611-
if notnan(val):
1609+
if val == val:
16121610
if pre_val == pre_val:
16131611
remove_weighted_var(pre_val, pre_w, &t,
16141612
&sum_w, &mean, &nobs)

0 commit comments

Comments
 (0)