Skip to content

Commit 54533f3

Browse files
committed
Simplify float NaN check
1 parent 848fcad commit 54533f3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pandas/_libs/tslibs/nattype.pyx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
from cpython cimport (
4-
PyFloat_Check, PyFloat_AS_DOUBLE, PyComplex_Check,
54
PyObject_RichCompare,
65
Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE)
76

@@ -12,7 +11,7 @@ PyDateTime_IMPORT
1211

1312
import numpy as np
1413
cimport numpy as cnp
15-
from numpy cimport int64_t
14+
from numpy cimport int64_t, float64_t
1615
cnp.import_array()
1716

1817
from pandas._libs.tslibs.np_datetime cimport (
@@ -715,12 +714,12 @@ NaT = c_NaT # Python-visible
715714
cdef inline bint checknull_with_nat(object val):
716715
""" utility to check if a value is a nat or not """
717716
cdef:
718-
double dval
717+
float64_t fval
719718
if val is None or val is c_NaT:
720719
return True
721-
if PyFloat_Check(val):
722-
dval = val
723-
return dval != dval
720+
if isinstance(val, float):
721+
fval = val
722+
return fval != fval
724723
return util.is_nan(val)
725724

726725

0 commit comments

Comments
 (0)