11# -*- coding: utf-8 -*-
2+ # cython: boundscheck=False, wraparound=False
23from datetime import datetime, date
34
45from cpython cimport (
@@ -46,7 +47,7 @@ from frequencies cimport (get_freq_code, get_base_alias,
4647 get_rule_month)
4748from parsing import parse_time_string
4849from resolution import Resolution
49- from nattype import nat_strings, NaT, iNaT
50+ from nattype import nat_strings, NaT
5051from nattype cimport _nat_scalar_rules, NPY_NAT, is_null_datetimelike
5152from offsets cimport to_offset
5253from offsets import _Tick
@@ -976,8 +977,6 @@ cdef inline int month_to_quarter(int month):
976977# Period logic
977978
978979
979- @ cython.wraparound (False )
980- @ cython.boundscheck (False )
981980def dt64arr_to_periodarr (int64_t[:] dtarr , int freq , tz = None ):
982981 """
983982 Convert array of datetime64 values (passed in as 'i8' dtype) to a set of
@@ -1005,8 +1004,6 @@ def dt64arr_to_periodarr(int64_t[:] dtarr, int freq, tz=None):
10051004 return out.base # .base to access underlying np.ndarray
10061005
10071006
1008- @ cython.wraparound (False )
1009- @ cython.boundscheck (False )
10101007def periodarr_to_dt64arr (int64_t[:] periodarr , int freq ):
10111008 """
10121009 Convert array to datetime64 values from a set of ordinals corresponding to
@@ -1040,8 +1037,8 @@ cpdef int64_t period_asfreq(int64_t ordinal, int freq1, int freq2, bint end):
10401037 freq_conv_func func
10411038 asfreq_info af_info
10421039
1043- if ordinal == iNaT :
1044- return iNaT
1040+ if ordinal == NPY_NAT :
1041+ return NPY_NAT
10451042
10461043 func = get_asfreq_func(freq1, freq2)
10471044 get_asfreq_info(freq1, freq2, end, & af_info)
@@ -1125,7 +1122,7 @@ def period_asfreq_arr(int64_t[:] arr, int freq1, int freq2, bint end):
11251122
11261123 for i in range (n):
11271124 val = arr[i]
1128- if val != iNaT :
1125+ if val != NPY_NAT :
11291126 val = func(val, & af_info)
11301127 if val == INT32_MIN:
11311128 raise ValueError (" Unable to convert to desired frequency." )
@@ -1183,7 +1180,7 @@ def period_format(int64_t value, int freq, object fmt=None):
11831180 cdef:
11841181 int freq_group
11851182
1186- if value == iNaT :
1183+ if value == NPY_NAT :
11871184 return repr (NaT)
11881185
11891186 if fmt is None :
@@ -1239,6 +1236,7 @@ cdef object _period_strftime(int64_t value, int freq, object fmt):
12391236 list found_pat = [False ] * len (extra_fmts)
12401237 int year, quarter
12411238
1239+
12421240 if isinstance (fmt, unicode ):
12431241 fmt = fmt.encode(' utf-8' )
12441242
@@ -1386,7 +1384,7 @@ def get_period_field_arr(int code, int64_t[:] arr, int freq):
13861384 out = np.empty(sz, dtype = np.int64)
13871385
13881386 for i in range (sz):
1389- if arr[i] == iNaT :
1387+ if arr[i] == NPY_NAT :
13901388 out[i] = - 1
13911389 continue
13921390 out[i] = func(arr[i], freq)
@@ -1434,7 +1432,7 @@ def extract_ordinals(object[:] values, freq):
14341432 p = values[i]
14351433
14361434 if is_null_datetimelike(p):
1437- ordinals[i] = iNaT
1435+ ordinals[i] = NPY_NAT
14381436 else :
14391437 try :
14401438 ordinals[i] = p.ordinal
@@ -1447,7 +1445,7 @@ def extract_ordinals(object[:] values, freq):
14471445 p = Period(p, freq = freq)
14481446 if p is NaT:
14491447 # input may contain NaT-like string
1450- ordinals[i] = iNaT
1448+ ordinals[i] = NPY_NAT
14511449 else :
14521450 ordinals[i] = p.ordinal
14531451
@@ -1475,8 +1473,6 @@ def extract_freq(object[:] values):
14751473# -----------------------------------------------------------------------
14761474# period helpers
14771475
1478- @ cython.wraparound (False )
1479- @ cython.boundscheck (False )
14801476cdef int64_t[:] localize_dt64arr_to_period(int64_t[:] stamps,
14811477 int freq, object tz):
14821478 cdef:
@@ -1572,7 +1568,7 @@ cdef class _Period(object):
15721568 """
15731569 Fast creation from an ordinal and freq that are already validated!
15741570 """
1575- if ordinal == iNaT :
1571+ if ordinal == NPY_NAT :
15761572 return NaT
15771573 else :
15781574 freq = cls ._maybe_convert_freq(freq)
@@ -2406,7 +2402,7 @@ class Period(_Period):
24062402 if (year is None and month is None and
24072403 quarter is None and day is None and
24082404 hour is None and minute is None and second is None ):
2409- ordinal = iNaT
2405+ ordinal = NPY_NAT
24102406 else :
24112407 if freq is None :
24122408 raise ValueError (" If value is None, freq cannot be None" )
@@ -2432,15 +2428,15 @@ class Period(_Period):
24322428 ordinal = converted.ordinal
24332429
24342430 elif is_null_datetimelike(value) or value in nat_strings:
2435- ordinal = iNaT
2431+ ordinal = NPY_NAT
24362432
24372433 elif is_string_object(value) or util.is_integer_object(value):
24382434 if util.is_integer_object(value):
24392435 value = str (value)
24402436 value = value.upper()
24412437 dt, _, reso = parse_time_string(value, freq)
24422438 if dt is NaT:
2443- ordinal = iNaT
2439+ ordinal = NPY_NAT
24442440
24452441 if freq is None :
24462442 try :
0 commit comments