Skip to content

REF: remove _get_join_target #43788

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
Sep 28, 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
24 changes: 10 additions & 14 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,17 @@ class Index(IndexOpsMixin, PandasObject):
@final
def _left_indexer_unique(self: _IndexT, other: _IndexT) -> npt.NDArray[np.intp]:
# Caller is responsible for ensuring other.dtype == self.dtype
sv = self._get_join_target()
ov = other._get_join_target()
sv = self._get_engine_target()
ov = other._get_engine_target()
return libjoin.left_join_indexer_unique(sv, ov)

@final
def _left_indexer(
self: _IndexT, other: _IndexT
) -> tuple[ArrayLike, npt.NDArray[np.intp], npt.NDArray[np.intp]]:
# Caller is responsible for ensuring other.dtype == self.dtype
sv = self._get_join_target()
ov = other._get_join_target()
sv = self._get_engine_target()
ov = other._get_engine_target()
joined_ndarray, lidx, ridx = libjoin.left_join_indexer(sv, ov)
joined = self._from_join_target(joined_ndarray)
return joined, lidx, ridx
Expand All @@ -335,8 +335,8 @@ def _inner_indexer(
self: _IndexT, other: _IndexT
) -> tuple[ArrayLike, npt.NDArray[np.intp], npt.NDArray[np.intp]]:
# Caller is responsible for ensuring other.dtype == self.dtype
sv = self._get_join_target()
ov = other._get_join_target()
sv = self._get_engine_target()
ov = other._get_engine_target()
joined_ndarray, lidx, ridx = libjoin.inner_join_indexer(sv, ov)
joined = self._from_join_target(joined_ndarray)
return joined, lidx, ridx
Expand All @@ -346,8 +346,8 @@ def _outer_indexer(
self: _IndexT, other: _IndexT
) -> tuple[ArrayLike, npt.NDArray[np.intp], npt.NDArray[np.intp]]:
# Caller is responsible for ensuring other.dtype == self.dtype
sv = self._get_join_target()
ov = other._get_join_target()
sv = self._get_engine_target()
ov = other._get_engine_target()
joined_ndarray, lidx, ridx = libjoin.outer_join_indexer(sv, ov)
joined = self._from_join_target(joined_ndarray)
return joined, lidx, ridx
Expand Down Expand Up @@ -894,6 +894,8 @@ def ravel(self, order="C"):
# Item "ndarray[Any, Any]" of "Union[ExtensionArray, ndarray[Any, Any]]"
# has no attribute "_ndarray"
values = self._data._ndarray # type: ignore[union-attr]
elif is_interval_dtype(self.dtype):
values = np.asarray(self._data)
else:
values = self._get_engine_target()
return values.ravel(order=order)
Expand Down Expand Up @@ -4618,12 +4620,6 @@ def _get_engine_target(self) -> np.ndarray:
# ndarray]", expected "ndarray")
return self._values # type: ignore[return-value]

def _get_join_target(self) -> np.ndarray:
"""
Get the ndarray that we will pass to libjoin functions.
"""
return self._get_engine_target()

def _from_join_target(self, result: np.ndarray) -> ArrayLike:
"""
Cast the ndarray returned from one of the libjoin.foo_indexer functions
Expand Down
3 changes: 0 additions & 3 deletions pandas/core/indexes/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@ def searchsorted(

# ---------------------------------------------------------------------

def _get_engine_target(self) -> np.ndarray:
return np.asarray(self._data)

def delete(self, loc):
"""
Make new Index with passed location(-s) deleted
Expand Down
7 changes: 5 additions & 2 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,11 +892,14 @@ def _is_all_dates(self) -> bool:
"""
return False

def _get_join_target(self) -> np.ndarray:
def _get_engine_target(self) -> np.ndarray:
# Note: we _could_ use libjoin functions by either casting to object
# dtype or constructing tuples (faster than constructing Intervals)
# but the libjoin fastpaths are no longer fast in these cases.
raise NotImplementedError("IntervalIndex does not use libjoin fastpaths")
raise NotImplementedError(
"IntervalIndex does not use libjoin fastpaths or pass values to "
"IndexEngine objects"
)

def _from_join_target(self, result):
raise NotImplementedError("IntervalIndex does not use libjoin fastpaths")
Expand Down