Skip to content

Commit dffbb29

Browse files
committed
Add patch for pandas 2.0.3
1 parent 2278b6c commit dffbb29

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

graalpython/lib-graalpython/patches/pandas/metadata.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ version = '== 2.2.2'
33
patch = 'pandas-2.2.2.patch'
44
dist-type = 'sdist'
55

6+
[[rules]]
7+
version = '== 2.0.3'
8+
patch = 'pandas-2.0.3.patch'
9+
dist-type = 'sdist'
10+
611
[[rules]]
712
version = '== 1.5.2'
813
patch = 'pandas-1.5.2.patch'
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
diff --git a/pandas/_libs/src/klib/khash_python.h b/pandas/_libs/src/klib/khash_python.h
2+
index 56afea0..14025b7 100644
3+
--- a/pandas/_libs/src/klib/khash_python.h
4+
+++ b/pandas/_libs/src/klib/khash_python.h
5+
@@ -178,28 +178,30 @@ int PANDAS_INLINE floatobject_cmp(PyFloatObject* a, PyFloatObject* b){
6+
// PyObject_RichCompareBool for complexobjects has a different behavior
7+
// needs to be replaced
8+
int PANDAS_INLINE complexobject_cmp(PyComplexObject* a, PyComplexObject* b){
9+
+ Py_complex a_cval = PyComplex_AsCComplex((PyObject*)a);
10+
+ Py_complex b_cval = PyComplex_AsCComplex((PyObject*)b);
11+
return (
12+
- Py_IS_NAN(a->cval.real) &&
13+
- Py_IS_NAN(b->cval.real) &&
14+
- Py_IS_NAN(a->cval.imag) &&
15+
- Py_IS_NAN(b->cval.imag)
16+
+ Py_IS_NAN(a_cval.real) &&
17+
+ Py_IS_NAN(b_cval.real) &&
18+
+ Py_IS_NAN(a_cval.imag) &&
19+
+ Py_IS_NAN(b_cval.imag)
20+
)
21+
||
22+
(
23+
- Py_IS_NAN(a->cval.real) &&
24+
- Py_IS_NAN(b->cval.real) &&
25+
- a->cval.imag == b->cval.imag
26+
+ Py_IS_NAN(a_cval.real) &&
27+
+ Py_IS_NAN(b_cval.real) &&
28+
+ a_cval.imag == b_cval.imag
29+
)
30+
||
31+
(
32+
- a->cval.real == b->cval.real &&
33+
- Py_IS_NAN(a->cval.imag) &&
34+
- Py_IS_NAN(b->cval.imag)
35+
+ a_cval.real == b_cval.real &&
36+
+ Py_IS_NAN(a_cval.imag) &&
37+
+ Py_IS_NAN(b_cval.imag)
38+
)
39+
||
40+
(
41+
- a->cval.real == b->cval.real &&
42+
- a->cval.imag == b->cval.imag
43+
+ a_cval.real == b_cval.real &&
44+
+ a_cval.imag == b_cval.imag
45+
);
46+
}
47+
48+
@@ -276,8 +278,9 @@ Py_hash_t PANDAS_INLINE floatobject_hash(PyFloatObject* key) {
49+
50+
// replaces _Py_HashDouble with _Pandas_HashDouble
51+
Py_hash_t PANDAS_INLINE complexobject_hash(PyComplexObject* key) {
52+
- Py_uhash_t realhash = (Py_uhash_t)_Pandas_HashDouble(key->cval.real);
53+
- Py_uhash_t imaghash = (Py_uhash_t)_Pandas_HashDouble(key->cval.imag);
54+
+ Py_complex cval = PyComplex_AsCComplex((PyObject*)key);
55+
+ Py_uhash_t realhash = (Py_uhash_t)_Pandas_HashDouble(cval.real);
56+
+ Py_uhash_t imaghash = (Py_uhash_t)_Pandas_HashDouble(cval.imag);
57+
if (realhash == (Py_uhash_t)-1 || imaghash == (Py_uhash_t)-1) {
58+
return -1;
59+
}
60+
diff --git a/setup.py b/setup.py
61+
index b6dfcc5..2446bcc 100755
62+
--- a/setup.py
63+
+++ b/setup.py
64+
@@ -421,7 +421,7 @@ def maybe_cythonize(extensions, *args, **kwargs):
65+
parser.add_argument("--parallel", "-j", type=int, default=1)
66+
parsed, _ = parser.parse_known_args()
67+
68+
- kwargs["nthreads"] = parsed.parallel
69+
+ kwargs["nthreads"] = 1 # parsed.parallel
70+
build_ext.render_templates(_pxifiles)
71+
return cythonize(extensions, *args, **kwargs)
72+

mx.graalpython/mx_graalpython.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,6 +2115,7 @@ def _python_checkpatchfiles():
21152115
'scipy-1.10.1.patch',
21162116
# pandas puts the whole license text in the field. Its BSD-3-Clause
21172117
'pandas-1.5.2.patch',
2118+
'pandas-2.0.3.patch',
21182119
'pandas-2.2.2.patch',
21192120
# numpy started putting the whole license text in the field. Its BSD-3-Clause
21202121
'numpy-1.23.2.patch',

0 commit comments

Comments
 (0)