@@ -107,7 +107,7 @@ def memory_usage_of_objects(object[:] arr):
107
107
# ----------------------------------------------------------------------
108
108
109
109
110
- cpdef bint is_scalar(object val) :
110
+ def is_scalar (val: object ) -> bint :
111
111
"""
112
112
Return True if given value is scalar.
113
113
@@ -137,7 +137,7 @@ cpdef bint is_scalar(object val):
137
137
or util.is_period_object(val )
138
138
or is_decimal(val )
139
139
or is_interval(val )
140
- or is_offset (val))
140
+ or util.is_offset_object (val ))
141
141
142
142
143
143
def item_from_zerodim(object val ):
@@ -457,7 +457,7 @@ def maybe_booleans_to_slice(ndarray[uint8_t] mask):
457
457
458
458
@ cython.wraparound (False )
459
459
@ cython.boundscheck (False )
460
- cpdef bint array_equivalent_object(object [:] left, object [:] right) :
460
+ def array_equivalent_object (left: object[:], right: object[:]) -> bint :
461
461
""" perform an element by element comparion on 1-d object arrays
462
462
taking into account nan positions """
463
463
cdef:
@@ -497,7 +497,7 @@ def astype_intsafe(ndarray[object] arr, new_dtype):
497
497
return result
498
498
499
499
500
- cpdef ndarray[ object ] astype_unicode(ndarray arr) :
500
+ def astype_unicode (arr: ndarray ) -> ndarray[object] :
501
501
cdef:
502
502
Py_ssize_t i , n = arr.size
503
503
ndarray[object] result = np.empty(n, dtype = object )
@@ -508,7 +508,7 @@ cpdef ndarray[object] astype_unicode(ndarray arr):
508
508
return result
509
509
510
510
511
- cpdef ndarray[ object ] astype_str(ndarray arr) :
511
+ def astype_str (arr: ndarray ) -> ndarray[object] :
512
512
cdef:
513
513
Py_ssize_t i , n = arr.size
514
514
ndarray[object] result = np.empty(n, dtype = object )
@@ -791,19 +791,19 @@ def indices_fast(object index, ndarray[int64_t] labels, list keys,
791
791
792
792
# core.common import for fast inference checks
793
793
794
- cpdef bint is_float(object obj) :
794
+ def is_float (obj: object ) -> bint :
795
795
return util.is_float_object(obj )
796
796
797
797
798
- cpdef bint is_integer(object obj) :
798
+ def is_integer(obj: object ) -> bint :
799
799
return util.is_integer_object(obj )
800
800
801
801
802
- cpdef bint is_bool(object obj) :
802
+ def is_bool(obj: object ) -> bint :
803
803
return util.is_bool_object(obj )
804
804
805
805
806
- cpdef bint is_complex(object obj) :
806
+ def is_complex(obj: object ) -> bint :
807
807
return util.is_complex_object(obj )
808
808
809
809
@@ -815,15 +815,11 @@ cpdef bint is_interval(object obj):
815
815
return getattr (obj, ' _typ' , ' _typ' ) == ' interval'
816
816
817
817
818
- cpdef bint is_period(object val) :
818
+ def is_period (val: object ) -> bint :
819
819
""" Return a boolean if this is a Period object """
820
820
return util.is_period_object(val )
821
821
822
822
823
- cdef inline bint is_offset(object val):
824
- return getattr (val, ' _typ' , ' _typ' ) == ' dateoffset'
825
-
826
-
827
823
_TYPE_MAP = {
828
824
' categorical' : ' categorical' ,
829
825
' category' : ' categorical' ,
@@ -1225,7 +1221,7 @@ def infer_dtype(object value, bint skipna=False):
1225
1221
if is_bytes_array(values, skipna = skipna):
1226
1222
return ' bytes'
1227
1223
1228
- elif is_period (val):
1224
+ elif util.is_period_object (val):
1229
1225
if is_period_array(values):
1230
1226
return ' period'
1231
1227
@@ -1243,7 +1239,7 @@ def infer_dtype(object value, bint skipna=False):
1243
1239
return ' mixed'
1244
1240
1245
1241
1246
- cpdef object infer_datetimelike_array(object arr) :
1242
+ def infer_datetimelike_array (arr: object ) -> object :
1247
1243
"""
1248
1244
infer if we have a datetime or timedelta array
1249
1245
- date: we have *only* date and maybe strings , nulls
@@ -1580,7 +1576,7 @@ cpdef bint is_datetime64_array(ndarray values):
1580
1576
return validator.validate(values)
1581
1577
1582
1578
1583
- cpdef bint is_datetime_with_singletz_array(ndarray values) :
1579
+ def is_datetime_with_singletz_array (values: ndarray ) -> bint :
1584
1580
"""
1585
1581
Check values have the same tzinfo attribute.
1586
1582
Doesn't check values are datetime-like types.
@@ -1616,7 +1612,8 @@ cdef class TimedeltaValidator(TemporalValidator):
1616
1612
return is_null_timedelta64(value)
1617
1613
1618
1614
1619
- cpdef bint is_timedelta_array(ndarray values):
1615
+ # TODO: Not used outside of tests; remove?
1616
+ def is_timedelta_array (values: ndarray ) -> bint:
1620
1617
cdef:
1621
1618
TimedeltaValidator validator = TimedeltaValidator(len (values),
1622
1619
skipna = True )
@@ -1628,7 +1625,8 @@ cdef class Timedelta64Validator(TimedeltaValidator):
1628
1625
return util.is_timedelta64_object(value)
1629
1626
1630
1627
1631
- cpdef bint is_timedelta64_array(ndarray values):
1628
+ # TODO: Not used outside of tests; remove?
1629
+ def is_timedelta64_array (values: ndarray ) -> bint:
1632
1630
cdef:
1633
1631
Timedelta64Validator validator = Timedelta64Validator(len (values),
1634
1632
skipna = True )
@@ -1672,7 +1670,7 @@ cpdef bint is_time_array(ndarray values, bint skipna=False):
1672
1670
1673
1671
cdef class PeriodValidator(TemporalValidator):
1674
1672
cdef inline bint is_value_typed(self , object value) except - 1 :
1675
- return is_period (value)
1673
+ return util.is_period_object (value)
1676
1674
1677
1675
cdef inline bint is_valid_null(self , object value) except - 1 :
1678
1676
return is_null_period(value)
0 commit comments