@@ -27,13 +27,12 @@ from datetime cimport (
27
27
INT32_MIN)
28
28
29
29
30
- cimport util, lib
30
+ cimport util
31
31
from util cimport is_period_object, is_string_object
32
32
33
- from lib cimport is_null_datetimelike, is_period
34
- from pandas._libs import tslib, lib
35
- from pandas._libs.tslib import (Timedelta, Timestamp, iNaT,
36
- NaT)
33
+ from lib cimport is_null_datetimelike
34
+ from pandas._libs import tslib
35
+ from pandas._libs.tslib import Timestamp, iNaT, NaT
37
36
from tslibs.timezones cimport (
38
37
is_utc, is_tzlocal, get_utcoffset, _get_dst_info, maybe_get_tz)
39
38
from tslib cimport _nat_scalar_rules
@@ -485,7 +484,7 @@ def extract_freq(ndarray[object] values):
485
484
486
485
try :
487
486
# now Timestamp / NaT has freq attr
488
- if is_period (p):
487
+ if is_period_object (p):
489
488
return p.freq
490
489
except AttributeError :
491
490
pass
@@ -728,8 +727,7 @@ cdef class _Period(object):
728
727
return hash ((self .ordinal, self .freqstr))
729
728
730
729
def _add_delta (self , other ):
731
- if isinstance (other, (timedelta, np.timedelta64,
732
- offsets.Tick, Timedelta)):
730
+ if isinstance (other, (timedelta, np.timedelta64, offsets.Tick)):
733
731
offset = frequencies.to_offset(self .freq.rule_code)
734
732
if isinstance (offset, offsets.Tick):
735
733
nanos = tslib._delta_to_nanoseconds(other)
@@ -754,12 +752,11 @@ cdef class _Period(object):
754
752
def __add__ (self , other ):
755
753
if is_period_object(self ):
756
754
if isinstance (other, (timedelta, np.timedelta64,
757
- offsets.DateOffset,
758
- Timedelta)):
755
+ offsets.DateOffset)):
759
756
return self ._add_delta(other)
760
757
elif other is NaT:
761
758
return NaT
762
- elif lib.is_integer (other):
759
+ elif util.is_integer_object (other):
763
760
ordinal = self .ordinal + other * self .freq.n
764
761
return Period(ordinal = ordinal, freq = self .freq)
765
762
else : # pragma: no cover
@@ -772,11 +769,10 @@ cdef class _Period(object):
772
769
def __sub__ (self , other ):
773
770
if is_period_object(self ):
774
771
if isinstance (other, (timedelta, np.timedelta64,
775
- offsets.DateOffset,
776
- Timedelta)):
772
+ offsets.DateOffset)):
777
773
neg_other = - other
778
774
return self + neg_other
779
- elif lib.is_integer (other):
775
+ elif util.is_integer_object (other):
780
776
ordinal = self .ordinal - other * self .freq.n
781
777
return Period(ordinal = ordinal, freq = self .freq)
782
778
elif is_period_object(other):
@@ -1159,7 +1155,7 @@ class Period(_Period):
1159
1155
raise ValueError ((" Only value or ordinal but not both should be "
1160
1156
" given but not both" ))
1161
1157
elif ordinal is not None :
1162
- if not lib.is_integer (ordinal):
1158
+ if not util.is_integer_object (ordinal):
1163
1159
raise ValueError (" Ordinal must be an integer" )
1164
1160
if freq is None :
1165
1161
raise ValueError (' Must supply freq for ordinal value' )
@@ -1196,8 +1192,8 @@ class Period(_Period):
1196
1192
elif is_null_datetimelike(value) or value in tslib._nat_strings:
1197
1193
ordinal = iNaT
1198
1194
1199
- elif is_string_object(value) or lib.is_integer (value):
1200
- if lib.is_integer (value):
1195
+ elif is_string_object(value) or util.is_integer_object (value):
1196
+ if util.is_integer_object (value):
1201
1197
value = str (value)
1202
1198
value = value.upper()
1203
1199
dt, _, reso = parse_time_string(value, freq)
0 commit comments