Skip to content

Commit a564662

Browse files
authored
CLN: use isnan() instead of the Py_IS_NAN macro (#58850)
1 parent b162331 commit a564662

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pandas/_libs/include/pandas/vendored/klib/khash_python.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,20 @@ KHASH_MAP_INIT_COMPLEX128(complex128, size_t)
156156

157157
// NaN-floats should be in the same equivalency class, see GH 22119
158158
static inline int floatobject_cmp(PyFloatObject *a, PyFloatObject *b) {
159-
return (Py_IS_NAN(PyFloat_AS_DOUBLE(a)) && Py_IS_NAN(PyFloat_AS_DOUBLE(b))) ||
159+
return (isnan(PyFloat_AS_DOUBLE(a)) && isnan(PyFloat_AS_DOUBLE(b))) ||
160160
(PyFloat_AS_DOUBLE(a) == PyFloat_AS_DOUBLE(b));
161161
}
162162

163163
// NaNs should be in the same equivalency class, see GH 41836
164164
// PyObject_RichCompareBool for complexobjects has a different behavior
165165
// needs to be replaced
166166
static inline int complexobject_cmp(PyComplexObject *a, PyComplexObject *b) {
167-
return (Py_IS_NAN(a->cval.real) && Py_IS_NAN(b->cval.real) &&
168-
Py_IS_NAN(a->cval.imag) && Py_IS_NAN(b->cval.imag)) ||
169-
(Py_IS_NAN(a->cval.real) && Py_IS_NAN(b->cval.real) &&
167+
return (isnan(a->cval.real) && isnan(b->cval.real) && isnan(a->cval.imag) &&
168+
isnan(b->cval.imag)) ||
169+
(isnan(a->cval.real) && isnan(b->cval.real) &&
170170
a->cval.imag == b->cval.imag) ||
171-
(a->cval.real == b->cval.real && Py_IS_NAN(a->cval.imag) &&
172-
Py_IS_NAN(b->cval.imag)) ||
171+
(a->cval.real == b->cval.real && isnan(a->cval.imag) &&
172+
isnan(b->cval.imag)) ||
173173
(a->cval.real == b->cval.real && a->cval.imag == b->cval.imag);
174174
}
175175

@@ -223,7 +223,7 @@ static inline int pyobject_cmp(PyObject *a, PyObject *b) {
223223

224224
static inline Py_hash_t _Pandas_HashDouble(double val) {
225225
// Since Python3.10, nan is no longer has hash 0
226-
if (Py_IS_NAN(val)) {
226+
if (isnan(val)) {
227227
return 0;
228228
}
229229
#if PY_VERSION_HEX < 0x030A0000

0 commit comments

Comments
 (0)