diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index f1f56c6c0c855..f7cec262ca302 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -74,6 +74,7 @@ cdef class IndexEngine: return val in self.mapping cpdef get_loc(self, object val): + # -> Py_ssize_t | slice | ndarray[bool] cdef: Py_ssize_t loc @@ -109,6 +110,7 @@ cdef class IndexEngine: raise KeyError(val) cdef inline _get_loc_duplicates(self, object val): + # -> Py_ssize_t | slice | ndarray[bool] cdef: Py_ssize_t diff @@ -142,6 +144,7 @@ cdef class IndexEngine: cdef _unpack_bool_indexer(self, ndarray[uint8_t, ndim=1, cast=True] indexer, object val): + # Returns ndarray[bool] or int cdef: ndarray[intp_t, ndim=1] found int count diff --git a/pandas/_libs/index_class_helper.pxi.in b/pandas/_libs/index_class_helper.pxi.in index 8638c2c689c3f..f0351e06f2b8c 100644 --- a/pandas/_libs/index_class_helper.pxi.in +++ b/pandas/_libs/index_class_helper.pxi.in @@ -44,8 +44,8 @@ cdef class {{name}}Engine(IndexEngine): raise KeyError(val) {{endif}} - cdef void _call_map_locations(self, ndarray values): - self.mapping.map_locations(algos.ensure_{{name.lower()}}(values)) + cdef void _call_map_locations(self, ndarray[{{dtype}}_t] values): + self.mapping.map_locations(values) cdef _maybe_get_bool_indexer(self, object val): # Returns ndarray[bool] or int diff --git a/pandas/_libs/intervaltree.pxi.in b/pandas/_libs/intervaltree.pxi.in index 1af5b23e3393f..0fb01a2188a57 100644 --- a/pandas/_libs/intervaltree.pxi.in +++ b/pandas/_libs/intervaltree.pxi.in @@ -73,7 +73,7 @@ cdef class IntervalTree(IntervalMixin): self.root = node_cls(self.left, self.right, indices, leaf_size) @property - def left_sorter(self): + def left_sorter(self) -> np.ndarray: """How to sort the left labels; this is used for binary search """ if self._left_sorter is None: @@ -81,7 +81,7 @@ cdef class IntervalTree(IntervalMixin): return self._left_sorter @property - def right_sorter(self): + def right_sorter(self) -> np.ndarray: """How to sort the right labels """ if self._right_sorter is None: @@ -89,7 +89,7 @@ cdef class IntervalTree(IntervalMixin): return self._right_sorter @property - def is_overlapping(self): + def is_overlapping(self) -> bool: """ Determine if the IntervalTree contains overlapping intervals. Cached as self._is_overlapping. @@ -109,7 +109,7 @@ cdef class IntervalTree(IntervalMixin): return self._is_overlapping @property - def is_monotonic_increasing(self): + def is_monotonic_increasing(self) -> bool: """ Return True if the IntervalTree is monotonic increasing (only equal or increasing values), else False @@ -119,7 +119,7 @@ cdef class IntervalTree(IntervalMixin): sort_order = np.lexsort(values) return is_monotonic(sort_order, False)[0] - def get_indexer(self, scalar_t[:] target): + def get_indexer(self, scalar_t[:] target) -> np.ndarray: """Return the positions corresponding to unique intervals that overlap with the given array of scalar targets. """ @@ -180,7 +180,7 @@ cdef class IntervalTree(IntervalMixin): n_elements=self.root.n_elements)) # compat with IndexEngine interface - def clear_mapping(self): + def clear_mapping(self) -> None: pass diff --git a/pandas/_libs/sparse.pyx b/pandas/_libs/sparse.pyx index 0c3d8915b749b..134883e159407 100644 --- a/pandas/_libs/sparse.pyx +++ b/pandas/_libs/sparse.pyx @@ -618,6 +618,7 @@ cdef class BlockIndex(SparseIndex): pass +@cython.internal cdef class BlockMerge: """ Object-oriented approach makes sharing state between recursive functions a @@ -661,6 +662,7 @@ cdef class BlockMerge: self.yi = xi +@cython.internal cdef class BlockUnion(BlockMerge): """ Object-oriented approach makes sharing state between recursive functions a diff --git a/pandas/_libs/tslibs/conversion.pxd b/pandas/_libs/tslibs/conversion.pxd index 1b99e855da40f..5b80193c1f27a 100644 --- a/pandas/_libs/tslibs/conversion.pxd +++ b/pandas/_libs/tslibs/conversion.pxd @@ -28,7 +28,7 @@ cdef _TSObject convert_datetime_to_tsobject(datetime ts, tzinfo tz, cdef int64_t get_datetime64_nanos(object val) except? -1 -cpdef datetime localize_pydatetime(datetime dt, object tz) +cpdef datetime localize_pydatetime(datetime dt, tzinfo tz) cdef int64_t cast_from_unit(object ts, str unit) except? -1 cpdef (int64_t, int) precision_from_unit(str unit) diff --git a/pandas/_libs/tslibs/conversion.pyx b/pandas/_libs/tslibs/conversion.pyx index 1bda35206ccef..865185f9acea7 100644 --- a/pandas/_libs/tslibs/conversion.pyx +++ b/pandas/_libs/tslibs/conversion.pyx @@ -810,14 +810,14 @@ cdef inline datetime _localize_pydatetime(datetime dt, tzinfo tz): return dt.replace(tzinfo=tz) -cpdef inline datetime localize_pydatetime(datetime dt, object tz): +cpdef inline datetime localize_pydatetime(datetime dt, tzinfo tz): """ Take a datetime/Timestamp in UTC and localizes to timezone tz. Parameters ---------- dt : datetime or Timestamp - tz : tzinfo, "UTC", or None + tz : tzinfo or None Returns -------