Skip to content

Commit 9b8f48a

Browse files
committed
math/py-pandas: Revert an upstream commit that broke the build.
- Pandas not only removed upstream a fix for MSVC but also removed what allowed us to have working std::signbit, see: pandas-dev/pandas#45008 - Revert that commit partially so that we fix the build error: pandas/_libs/window/aggregations.cpp:4951:18: error: 'signbit' was not declared in this scope
1 parent b5a008b commit 9b8f48a

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PLIST_FILES+= %%PYTHON_SITELIBDIR%%/pandas/_libs/src/headers/cmath
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--- pandas/_libs/src/headers/cmath.orig 2023-01-25 23:09:18 UTC
2+
+++ pandas/_libs/src/headers/cmath
3+
@@ -0,0 +1,48 @@
4+
+#ifndef _PANDAS_MATH_H_
5+
+#define _PANDAS_MATH_H_
6+
+
7+
+// MSVC 2017 has a bug where `x == x` can be true for NaNs.
8+
+// MSC_VER from https://stackoverflow.com/a/70630/1889400
9+
+// Place upper bound on this check once a fixed MSVC is released.
10+
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
11+
+#include <cmath>
12+
+// In older versions of Visual Studio there wasn't a std::signbit defined
13+
+// This defines it using _copysign
14+
+namespace std {
15+
+ __inline int isnan(double x) { return _isnan(x); }
16+
+ __inline int signbit(double num) { return _copysign(1.0, num) < 0; }
17+
+ __inline int notnan(double x) { return !isnan(x); }
18+
+}
19+
+#elif defined(_MSC_VER) && (_MSC_VER >= 1900)
20+
+#include <cmath>
21+
+namespace std {
22+
+ __inline int isnan(double x) { return _isnan(x); }
23+
+ __inline int notnan(double x) { return !isnan(x); }
24+
+}
25+
+#elif defined(_MSC_VER)
26+
+#include <cmath>
27+
+namespace std {
28+
+ __inline int isnan(double x) { return _isnan(x); }
29+
+ __inline int notnan(double x) { return x == x; }
30+
+}
31+
+#elif defined(__MVS__)
32+
+#include <cmath>
33+
+
34+
+#define _signbit signbit
35+
+#undef signbit
36+
+#undef isnan
37+
+
38+
+namespace std {
39+
+ __inline int notnan(double x) { return x == x; }
40+
+ __inline int signbit(double num) { return _signbit(num); }
41+
+ __inline int isnan(double x) { return isnan(x); }
42+
+}
43+
+#else
44+
+#include <cmath>
45+
+
46+
+namespace std {
47+
+ __inline int notnan(double x) { return x == x; }
48+
+}
49+
+
50+
+#endif
51+
+#endif
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--- pandas/_libs/window/aggregations.pyx.orig 2022-08-23 17:15:49 UTC
2+
+++ pandas/_libs/window/aggregations.pyx
3+
@@ -17,11 +17,18 @@ from numpy cimport (
4+
float32_t,
5+
float64_t,
6+
int64_t,
7+
- ndarray,
8+
+ ndarray
9+
)
10+
11+
cnp.import_array()
12+
13+
+cdef extern from "../src/headers/cmath" namespace "std":
14+
+ bint isnan(float64_t) nogil
15+
+ bint notnan(float64_t) nogil
16+
+ int signbit(float64_t) nogil
17+
+ float64_t sqrt(float64_t x) nogil
18+
+
19+
+
20+
from pandas._libs.algos import is_monotonic
21+
22+
from pandas._libs.dtypes cimport numeric_t

0 commit comments

Comments
 (0)