Skip to content

Commit 1546c35

Browse files
Windows CI (pandas-dev#23182)
1 parent 9285820 commit 1546c35

File tree

3 files changed

+45
-23
lines changed

3 files changed

+45
-23
lines changed

ci/azure-windows-36.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ channels:
55
dependencies:
66
- blosc
77
- bottleneck
8+
- boost-cpp<1.67
89
- fastparquet
910
- feather-format
1011
- matplotlib
1112
- numexpr
1213
- numpy=1.14*
1314
- openpyxl=2.5.5
15+
- parquet-cpp
1416
- pyarrow
1517
- pytables
1618
- python-dateutil

pandas/_libs/src/headers/cmath

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
#ifndef _PANDAS_MATH_H_
22
#define _PANDAS_MATH_H_
33

4+
// MSVC 2017 has a bug where `x == x` can be true for NaNs.
5+
// MSC_VER from https://stackoverflow.com/a/70630/1889400
6+
// Place upper bound on this check once a fixed MSVC is released.
7+
#if defined(_MSC_VER) && (_MSC_VER < 1800)
8+
#include <cmath>
49
// In older versions of Visual Studio there wasn't a std::signbit defined
510
// This defines it using _copysign
6-
#if defined(_MSC_VER) && (_MSC_VER < 1800)
11+
namespace std {
12+
__inline int isnan(double x) { return _isnan(x); }
13+
__inline int signbit(double num) { return _copysign(1.0, num) < 0; }
14+
__inline int notnan(double x) { return !isnan(x); }
15+
}
16+
#elif defined(_MSC_VER) && (_MSC_VER >= 1900)
17+
#include <cmath>
18+
namespace std {
19+
__inline int isnan(double x) { return _isnan(x); }
20+
__inline int notnan(double x) { return !isnan(x); }
21+
}
22+
#elif defined(_MSC_VER)
723
#include <cmath>
824
namespace std {
925
__inline int isnan(double x) { return _isnan(x); }
10-
__inline int signbit(double num) { return _copysign(1.0, num) < 0; }
26+
__inline int notnan(double x) { return x == x; }
1127
}
1228
#else
1329
#include <cmath>
14-
#endif
1530

31+
namespace std {
32+
__inline int notnan(double x) { return x == x; }
33+
}
34+
35+
#endif
1636
#endif

pandas/_libs/window.pyx

+20-20
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cnp.import_array()
1515

1616
cdef extern from "src/headers/cmath" namespace "std":
1717
bint isnan(double) nogil
18+
bint notnan(double) nogil
1819
int signbit(double) nogil
1920
double sqrt(double x) nogil
2021

@@ -381,21 +382,21 @@ def roll_count(ndarray[double_t] input, int64_t win, int64_t minp,
381382
count_x = 0.0
382383
for j in range(s, e):
383384
val = input[j]
384-
if val == val:
385+
if notnan(val):
385386
count_x += 1.0
386387

387388
else:
388389

389390
# calculate deletes
390391
for j in range(start[i - 1], s):
391392
val = input[j]
392-
if val == val:
393+
if notnan(val):
393394
count_x -= 1.0
394395

395396
# calculate adds
396397
for j in range(end[i - 1], e):
397398
val = input[j]
398-
if val == val:
399+
if notnan(val):
399400
count_x += 1.0
400401

401402
if count_x >= minp:
@@ -424,15 +425,15 @@ cdef inline void add_sum(double val, int64_t *nobs, double *sum_x) nogil:
424425
""" add a value from the sum calc """
425426

426427
# Not NaN
427-
if val == val:
428+
if notnan(val):
428429
nobs[0] = nobs[0] + 1
429430
sum_x[0] = sum_x[0] + val
430431

431432

432433
cdef inline void remove_sum(double val, int64_t *nobs, double *sum_x) nogil:
433434
""" remove a value from the sum calc """
434435

435-
if val == val:
436+
if notnan(val):
436437
nobs[0] = nobs[0] - 1
437438
sum_x[0] = sum_x[0] - val
438439

@@ -538,7 +539,7 @@ cdef inline void add_mean(double val, Py_ssize_t *nobs, double *sum_x,
538539
""" add a value from the mean calc """
539540

540541
# Not NaN
541-
if val == val:
542+
if notnan(val):
542543
nobs[0] = nobs[0] + 1
543544
sum_x[0] = sum_x[0] + val
544545
if signbit(val):
@@ -549,7 +550,7 @@ cdef inline void remove_mean(double val, Py_ssize_t *nobs, double *sum_x,
549550
Py_ssize_t *neg_ct) nogil:
550551
""" remove a value from the mean calc """
551552

552-
if val == val:
553+
if notnan(val):
553554
nobs[0] = nobs[0] - 1
554555
sum_x[0] = sum_x[0] - val
555556
if signbit(val):
@@ -671,8 +672,7 @@ cdef inline void remove_var(double val, double *nobs, double *mean_x,
671672
""" remove a value from the var calc """
672673
cdef double delta
673674

674-
# Not NaN
675-
if val == val:
675+
if notnan(val):
676676
nobs[0] = nobs[0] - 1
677677
if nobs[0]:
678678
# a part of Welford's method for the online variance-calculation
@@ -760,7 +760,7 @@ def roll_var(ndarray[double_t] input, int64_t win, int64_t minp,
760760
val = input[i]
761761
prev = input[i - win]
762762

763-
if val == val:
763+
if notnan(val):
764764
if prev == prev:
765765

766766
# Adding one observation and removing another one
@@ -822,7 +822,7 @@ cdef inline void add_skew(double val, int64_t *nobs, double *x, double *xx,
822822
""" add a value from the skew calc """
823823

824824
# Not NaN
825-
if val == val:
825+
if notnan(val):
826826
nobs[0] = nobs[0] + 1
827827

828828
# seriously don't ask me why this is faster
@@ -836,7 +836,7 @@ cdef inline void remove_skew(double val, int64_t *nobs, double *x, double *xx,
836836
""" remove a value from the skew calc """
837837

838838
# Not NaN
839-
if val == val:
839+
if notnan(val):
840840
nobs[0] = nobs[0] - 1
841841

842842
# seriously don't ask me why this is faster
@@ -959,7 +959,7 @@ cdef inline void add_kurt(double val, int64_t *nobs, double *x, double *xx,
959959
""" add a value from the kurotic calc """
960960

961961
# Not NaN
962-
if val == val:
962+
if notnan(val):
963963
nobs[0] = nobs[0] + 1
964964

965965
# seriously don't ask me why this is faster
@@ -974,7 +974,7 @@ cdef inline void remove_kurt(double val, int64_t *nobs, double *x, double *xx,
974974
""" remove a value from the kurotic calc """
975975

976976
# Not NaN
977-
if val == val:
977+
if notnan(val):
978978
nobs[0] = nobs[0] - 1
979979

980980
# seriously don't ask me why this is faster
@@ -1089,7 +1089,7 @@ def roll_median_c(ndarray[float64_t] input, int64_t win, int64_t minp,
10891089

10901090
# setup
10911091
val = input[i]
1092-
if val == val:
1092+
if notnan(val):
10931093
nobs += 1
10941094
err = skiplist_insert(sl, val) != 1
10951095
if err:
@@ -1100,14 +1100,14 @@ def roll_median_c(ndarray[float64_t] input, int64_t win, int64_t minp,
11001100
# calculate deletes
11011101
for j in range(start[i - 1], s):
11021102
val = input[j]
1103-
if val == val:
1103+
if notnan(val):
11041104
skiplist_remove(sl, val)
11051105
nobs -= 1
11061106

11071107
# calculate adds
11081108
for j in range(end[i - 1], e):
11091109
val = input[j]
1110-
if val == val:
1110+
if notnan(val):
11111111
nobs += 1
11121112
err = skiplist_insert(sl, val) != 1
11131113
if err:
@@ -1472,7 +1472,7 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,
14721472

14731473
# setup
14741474
val = input[i]
1475-
if val == val:
1475+
if notnan(val):
14761476
nobs += 1
14771477
skiplist_insert(skiplist, val)
14781478

@@ -1481,14 +1481,14 @@ def roll_quantile(ndarray[float64_t, cast=True] input, int64_t win,
14811481
# calculate deletes
14821482
for j in range(start[i - 1], s):
14831483
val = input[j]
1484-
if val == val:
1484+
if notnan(val):
14851485
skiplist_remove(skiplist, val)
14861486
nobs -= 1
14871487

14881488
# calculate adds
14891489
for j in range(end[i - 1], e):
14901490
val = input[j]
1491-
if val == val:
1491+
if notnan(val):
14921492
nobs += 1
14931493
skiplist_insert(skiplist, val)
14941494

0 commit comments

Comments
 (0)