@@ -107,7 +107,7 @@ def memory_usage_of_objects(object[:] arr):
107107# ----------------------------------------------------------------------
108108
109109
110- cpdef bint is_scalar(object val) :
110+ def is_scalar (val: object ) -> bint :
111111 """
112112 Return True if given value is scalar.
113113
@@ -137,7 +137,7 @@ cpdef bint is_scalar(object val):
137137 or util.is_period_object(val )
138138 or is_decimal(val )
139139 or is_interval(val )
140- or is_offset (val))
140+ or util.is_offset_object (val ))
141141
142142
143143def item_from_zerodim(object val ):
@@ -457,7 +457,7 @@ def maybe_booleans_to_slice(ndarray[uint8_t] mask):
457457
458458@ cython.wraparound (False )
459459@ cython.boundscheck (False )
460- cpdef bint array_equivalent_object(object [:] left, object [:] right) :
460+ def array_equivalent_object (left: object[:], right: object[:]) -> bint :
461461 """ perform an element by element comparion on 1-d object arrays
462462 taking into account nan positions """
463463 cdef:
@@ -497,7 +497,7 @@ def astype_intsafe(ndarray[object] arr, new_dtype):
497497 return result
498498
499499
500- cpdef ndarray[ object ] astype_unicode(ndarray arr) :
500+ def astype_unicode (arr: ndarray ) -> ndarray[object] :
501501 cdef:
502502 Py_ssize_t i , n = arr.size
503503 ndarray[object] result = np.empty(n, dtype = object )
@@ -508,7 +508,7 @@ cpdef ndarray[object] astype_unicode(ndarray arr):
508508 return result
509509
510510
511- cpdef ndarray[ object ] astype_str(ndarray arr) :
511+ def astype_str (arr: ndarray ) -> ndarray[object] :
512512 cdef:
513513 Py_ssize_t i , n = arr.size
514514 ndarray[object] result = np.empty(n, dtype = object )
@@ -791,19 +791,19 @@ def indices_fast(object index, ndarray[int64_t] labels, list keys,
791791
792792# core.common import for fast inference checks
793793
794- cpdef bint is_float(object obj) :
794+ def is_float (obj: object ) -> bint :
795795 return util.is_float_object(obj )
796796
797797
798- cpdef bint is_integer(object obj) :
798+ def is_integer(obj: object ) -> bint :
799799 return util.is_integer_object(obj )
800800
801801
802- cpdef bint is_bool(object obj) :
802+ def is_bool(obj: object ) -> bint :
803803 return util.is_bool_object(obj )
804804
805805
806- cpdef bint is_complex(object obj) :
806+ def is_complex(obj: object ) -> bint :
807807 return util.is_complex_object(obj )
808808
809809
@@ -815,15 +815,11 @@ cpdef bint is_interval(object obj):
815815 return getattr (obj, ' _typ' , ' _typ' ) == ' interval'
816816
817817
818- cpdef bint is_period(object val) :
818+ def is_period (val: object ) -> bint :
819819 """ Return a boolean if this is a Period object """
820820 return util.is_period_object(val )
821821
822822
823- cdef inline bint is_offset(object val):
824- return getattr (val, ' _typ' , ' _typ' ) == ' dateoffset'
825-
826-
827823_TYPE_MAP = {
828824 ' categorical' : ' categorical' ,
829825 ' category' : ' categorical' ,
@@ -1225,7 +1221,7 @@ def infer_dtype(object value, bint skipna=False):
12251221 if is_bytes_array(values, skipna = skipna):
12261222 return ' bytes'
12271223
1228- elif is_period (val):
1224+ elif util.is_period_object (val):
12291225 if is_period_array(values):
12301226 return ' period'
12311227
@@ -1243,7 +1239,7 @@ def infer_dtype(object value, bint skipna=False):
12431239 return ' mixed'
12441240
12451241
1246- cpdef object infer_datetimelike_array(object arr) :
1242+ def infer_datetimelike_array (arr: object ) -> object :
12471243 """
12481244 infer if we have a datetime or timedelta array
12491245 - date: we have *only* date and maybe strings , nulls
@@ -1580,7 +1576,7 @@ cpdef bint is_datetime64_array(ndarray values):
15801576 return validator.validate(values)
15811577
15821578
1583- cpdef bint is_datetime_with_singletz_array(ndarray values) :
1579+ def is_datetime_with_singletz_array (values: ndarray ) -> bint :
15841580 """
15851581 Check values have the same tzinfo attribute.
15861582 Doesn't check values are datetime-like types.
@@ -1616,7 +1612,8 @@ cdef class TimedeltaValidator(TemporalValidator):
16161612 return is_null_timedelta64(value)
16171613
16181614
1619- cpdef bint is_timedelta_array(ndarray values):
1615+ # TODO: Not used outside of tests; remove?
1616+ def is_timedelta_array (values: ndarray ) -> bint:
16201617 cdef:
16211618 TimedeltaValidator validator = TimedeltaValidator(len (values),
16221619 skipna = True )
@@ -1628,7 +1625,8 @@ cdef class Timedelta64Validator(TimedeltaValidator):
16281625 return util.is_timedelta64_object(value)
16291626
16301627
1631- cpdef bint is_timedelta64_array(ndarray values):
1628+ # TODO: Not used outside of tests; remove?
1629+ def is_timedelta64_array (values: ndarray ) -> bint:
16321630 cdef:
16331631 Timedelta64Validator validator = Timedelta64Validator(len (values),
16341632 skipna = True )
@@ -1672,7 +1670,7 @@ cpdef bint is_time_array(ndarray values, bint skipna=False):
16721670
16731671cdef class PeriodValidator(TemporalValidator):
16741672 cdef inline bint is_value_typed(self , object value) except - 1 :
1675- return is_period (value)
1673+ return util.is_period_object (value)
16761674
16771675 cdef inline bint is_valid_null(self , object value) except - 1 :
16781676 return is_null_period(value)
0 commit comments