Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel.oranyeli committed Sep 18, 2024
1 parent bfea362 commit cc66145
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions janitor/functions/_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,29 +564,6 @@ def _numba_equi_join_range_join(
return l_index, r_index


@njit
def _numba_less_than(arr: np.ndarray, value: Any):
"""
Get earliest position in `arr`
where arr[i] <= `value`
"""
min_idx = 0
max_idx = len(arr)
while min_idx < max_idx:
# to avoid overflow
mid_idx = min_idx + ((max_idx - min_idx) >> 1)
_mid_idx = np.uint64(mid_idx)
if arr[_mid_idx] < value:
min_idx = mid_idx + 1
else:
max_idx = mid_idx
# it is greater than
# the max value in the array
if min_idx == len(arr):
return -1
return min_idx


def _numba_single_non_equi_join(
left: pd.Series, right: pd.Series, op: str, keep: str
) -> tuple[np.ndarray, np.ndarray]:
Expand Down Expand Up @@ -1175,6 +1152,29 @@ def _numba_multiple_non_equi_join(
return left_indices, right_indices


@njit
def _numba_less_than(arr: np.ndarray, value: Any):
"""
Get earliest position in `arr`
where arr[i] <= `value`
"""
min_idx = 0
max_idx = len(arr)
while min_idx < max_idx:
# to avoid overflow
mid_idx = min_idx + ((max_idx - min_idx) >> 1)
_mid_idx = np.uint64(mid_idx)
if arr[_mid_idx] < value:
min_idx = mid_idx + 1
else:
max_idx = mid_idx
# it is greater than
# the max value in the array
if min_idx == len(arr):
return -1
return min_idx


@njit(cache=True)
def _numba_non_equi_join_not_monotonic_keep_all(
left_regions: np.ndarray,
Expand Down

0 comments on commit cc66145

Please sign in to comment.