Skip to content

Commit ccbd641

Browse files
authored
Merge pull request #24575 from oscargus/isnan
Use std::isnan and fix compiler warning
2 parents 116ace5 + ec144a9 commit ccbd641

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/_path.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,16 +1250,14 @@ struct _is_sorted
12501250
{
12511251
npy_intp size;
12521252
npy_intp i;
1253-
T last_value;
1253+
T last_value = -INFINITY;
12541254
T current_value;
12551255

12561256
size = PyArray_DIM(array, 0);
12571257

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

12721270
for (; i < size; ++i) {
12731271
current_value = *((T *)PyArray_GETPTR1(array, i));
1274-
if (current_value == current_value) {
1272+
if (!std::isnan(current_value)) {
12751273
if (current_value < last_value) {
12761274
return false;
12771275
}

0 commit comments

Comments
 (0)