Skip to content

Commit 2786fac

Browse files
jbrockmendelNo-Stream
authored andcommitted
Move NaT to self-contained module (pandas-dev#18014)
1 parent e0105c9 commit 2786fac

File tree

13 files changed

+589
-376
lines changed

13 files changed

+589
-376
lines changed

pandas/_libs/period.pyx

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ from pandas._libs import tslib
3030
from pandas._libs.tslib import Timestamp, iNaT, NaT
3131
from tslibs.timezones cimport (
3232
is_utc, is_tzlocal, get_utcoffset, get_dst_info, maybe_get_tz)
33-
from tslib cimport _nat_scalar_rules
3433

3534
from tslibs.parsing import parse_time_string, NAT_SENTINEL
3635
from tslibs.frequencies cimport get_freq_code
36+
from tslibs.nattype import nat_strings
37+
from tslibs.nattype cimport _nat_scalar_rules
3738

3839
from pandas.tseries import offsets
3940
from pandas.tseries import frequencies
@@ -1174,7 +1175,7 @@ class Period(_Period):
11741175
converted = other.asfreq(freq)
11751176
ordinal = converted.ordinal
11761177

1177-
elif is_null_datetimelike(value) or value in tslib._nat_strings:
1178+
elif is_null_datetimelike(value) or value in nat_strings:
11781179
ordinal = iNaT
11791180

11801181
elif is_string_object(value) or util.is_integer_object(value):

pandas/_libs/src/inference.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from decimal import Decimal
33
cimport util
44
cimport cython
5-
from tslib import NaT
5+
from tslibs.nattype import NaT
66
from tslib cimport convert_to_tsobject, convert_to_timedelta64
77
from tslibs.timezones cimport get_timezone
88
from datetime import datetime, timedelta

pandas/_libs/src/ujson/python/objToJSON.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void initObjToJSON(void)
162162
#endif
163163
{
164164
PyObject *mod_pandas;
165-
PyObject *mod_tslib;
165+
PyObject *mod_nattype;
166166
PyObject *mod_decimal = PyImport_ImportModule("decimal");
167167
type_decimal = PyObject_GetAttrString(mod_decimal, "Decimal");
168168
Py_INCREF(type_decimal);
@@ -180,10 +180,11 @@ void initObjToJSON(void)
180180
Py_DECREF(mod_pandas);
181181
}
182182

183-
mod_tslib = PyImport_ImportModule("pandas._libs.tslib");
184-
if (mod_tslib) {
185-
cls_nat = (PyTypeObject *)PyObject_GetAttrString(mod_tslib, "NaTType");
186-
Py_DECREF(mod_tslib);
183+
mod_nattype = PyImport_ImportModule("pandas._libs.tslibs.nattype");
184+
if (mod_nattype) {
185+
cls_nat = (PyTypeObject *)PyObject_GetAttrString(mod_nattype,
186+
"NaTType");
187+
Py_DECREF(mod_nattype);
187188
}
188189

189190
/* Initialise numpy API and use 2/3 compatible return */

pandas/_libs/tslib.pxd

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ from numpy cimport ndarray, int64_t
22

33
cdef convert_to_tsobject(object, object, object, bint, bint)
44
cpdef convert_to_timedelta64(object, object)
5-
cdef bint _nat_scalar_rules[6]
65
cdef bint _check_all_nulls(obj)
76

87
cdef _to_i8(object val)

0 commit comments

Comments
 (0)