Skip to content

TYP: Index methods #43137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ def _reduce(
)
return func(skipna=skipna, **kwds)

@final
def _map_values(self, mapper, na_action=None):
"""
An internal function that maps values using the input
Expand Down
14 changes: 7 additions & 7 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3607,7 +3607,7 @@ def _get_indexer(
method: str_t | None = None,
limit: int | None = None,
tolerance=None,
) -> np.ndarray:
) -> npt.NDArray[np.intp]:
if tolerance is not None:
tolerance = self._convert_tolerance(tolerance, target)

Expand Down Expand Up @@ -3686,7 +3686,7 @@ def _convert_tolerance(self, tolerance, target: np.ndarray | Index) -> np.ndarra
@final
def _get_fill_indexer(
self, target: Index, method: str_t, limit: int | None = None, tolerance=None
) -> np.ndarray:
) -> npt.NDArray[np.intp]:

if self._is_multi:
# TODO: get_indexer_with_fill docstring says values must be _sorted_
Expand All @@ -3713,7 +3713,7 @@ def _get_fill_indexer(
@final
def _get_fill_indexer_searchsorted(
self, target: Index, method: str_t, limit: int | None = None
) -> np.ndarray:
) -> npt.NDArray[np.intp]:
"""
Fallback pad/backfill get_indexer that works for monotonic decreasing
indexes and non-monotonic targets.
Expand Down Expand Up @@ -3747,7 +3747,7 @@ def _get_fill_indexer_searchsorted(
@final
def _get_nearest_indexer(
self, target: Index, limit: int | None, tolerance
) -> np.ndarray:
) -> npt.NDArray[np.intp]:
"""
Get the indexer for the nearest index labels; requires an index with
values that can be subtracted from each other (e.g., not strings or
Expand Down Expand Up @@ -3777,10 +3777,10 @@ def _get_nearest_indexer(
@final
def _filter_indexer_tolerance(
self,
target: Index | np.ndarray | ExtensionArray,
indexer: np.ndarray,
target: np.ndarray,
indexer: npt.NDArray[np.intp],
tolerance,
) -> np.ndarray:
) -> npt.NDArray[np.intp]:
own_values = self._get_engine_target()
distance = abs(own_values[indexer] - target)
return np.where(distance <= tolerance, indexer, -1)
Expand Down