Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: use isnan() instead of the Py_IS_NAN macro #58850

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pandas/_libs/include/pandas/vendored/klib/khash_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ KHASH_MAP_INIT_COMPLEX128(complex128, size_t)

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

// NaNs should be in the same equivalency class, see GH 41836
// PyObject_RichCompareBool for complexobjects has a different behavior
// needs to be replaced
static inline int complexobject_cmp(PyComplexObject *a, PyComplexObject *b) {
return (Py_IS_NAN(a->cval.real) && Py_IS_NAN(b->cval.real) &&
Py_IS_NAN(a->cval.imag) && Py_IS_NAN(b->cval.imag)) ||
(Py_IS_NAN(a->cval.real) && Py_IS_NAN(b->cval.real) &&
return (isnan(a->cval.real) && isnan(b->cval.real) && isnan(a->cval.imag) &&
isnan(b->cval.imag)) ||
(isnan(a->cval.real) && isnan(b->cval.real) &&
a->cval.imag == b->cval.imag) ||
(a->cval.real == b->cval.real && Py_IS_NAN(a->cval.imag) &&
Py_IS_NAN(b->cval.imag)) ||
(a->cval.real == b->cval.real && isnan(a->cval.imag) &&
isnan(b->cval.imag)) ||
(a->cval.real == b->cval.real && a->cval.imag == b->cval.imag);
}

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

static inline Py_hash_t _Pandas_HashDouble(double val) {
// Since Python3.10, nan is no longer has hash 0
if (Py_IS_NAN(val)) {
if (isnan(val)) {
return 0;
}
#if PY_VERSION_HEX < 0x030A0000
Expand Down