Skip to content

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
  • Loading branch information
dchigarev committed Nov 29, 2021
1 parent 813037b commit e9ba2d5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modin/pandas/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

import numpy as np
import pandas
import itertools
from pandas.api.types import is_list_like, is_bool
from pandas.core.dtypes.common import is_integer, is_bool_dtype, is_integer_dtype
from pandas.core.indexing import IndexingError
from modin.error_message import ErrorMessage
from itertools import compress

from .dataframe import DataFrame
from .series import Series
Expand Down Expand Up @@ -222,7 +222,7 @@ def boolean_mask_to_numeric(indexer):
return np.fromiter(
# `itertools.compress` masks `data` with the `selectors` mask,
# works about ~10% faster than a pure list comprehension
compress(data=range(len(indexer)), selectors=indexer),
itertools.compress(data=range(len(indexer)), selectors=indexer),
dtype=np.int64,
)

Expand Down Expand Up @@ -793,7 +793,7 @@ def _compute_lookup(self, row_loc, col_loc):
axis_lookup = axis_labels.slice_indexer(
axis_loc.start, axis_loc.stop, axis_loc.step
)
# Converting negative indices to its actual positions:
# Converting negative indices to their actual positions:
axis_lookup = pandas.RangeIndex(
start=(
axis_lookup.start
Expand Down Expand Up @@ -835,9 +835,11 @@ def _compute_lookup(self, row_loc, col_loc):
# on masking non-maskable list-like
np.array(axis_loc)[missing_mask]
if is_list_like(axis_loc)
# If `axis_loc` is not a list-like then we can't select certain
# labels that are missing and so printing the whole indexer
else axis_loc
)
raise KeyError(f"Missing labels were provided: {missing_labels}")
raise KeyError(missing_labels)

if isinstance(axis_lookup, pandas.Index) and not is_range_like(axis_lookup):
axis_lookup = axis_lookup.values
Expand Down Expand Up @@ -975,7 +977,7 @@ def _compute_lookup(self, row_loc, col_loc):
# speedup covers the loss that we gain here.
axis_loc = np.array(axis_loc, dtype=np.int64)
# Relatively fast check allows us to not trigger `self.qc.get_axis()` computation
# if there're no negative indices and so they're not depend on the axis length.
# if there're no negative indices and so they don't not depend on the axis length.
if isinstance(axis_loc, np.ndarray) and not (axis_loc < 0).any():
axis_lookup = axis_loc
else:
Expand Down

0 comments on commit e9ba2d5

Please sign in to comment.