Skip to content

Use std::isnan and fix compiler warning #24575

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

Merged
merged 1 commit into from
Dec 2, 2022
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
8 changes: 3 additions & 5 deletions src/_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -1250,16 +1250,14 @@ struct _is_sorted
{
npy_intp size;
npy_intp i;
T last_value;
T last_value = -INFINITY;
T current_value;

size = PyArray_DIM(array, 0);

// std::isnan is only in C++11, which we don't yet require,
// so we use the "self == self" trick
for (i = 0; i < size; ++i) {
last_value = *((T *)PyArray_GETPTR1(array, i));
if (last_value == last_value) {
if (!std::isnan(last_value)) {
break;
}
}
Expand All @@ -1271,7 +1269,7 @@ struct _is_sorted

for (; i < size; ++i) {
current_value = *((T *)PyArray_GETPTR1(array, i));
if (current_value == current_value) {
if (!std::isnan(current_value)) {
if (current_value < last_value) {
return false;
}
Expand Down