Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
noloerino committed Sep 18, 2024
1 parent 3161540 commit 40cf94e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
4 changes: 3 additions & 1 deletion modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ def _build_repr_df(
A pandas dataset with `num_rows` or fewer rows and `num_cols` or fewer columns.
"""
# Fast track for empty dataframe.
if len(self) == 0 or (self._is_dataframe and self._query_compiler.get_axis_len(1) == 0):
if len(self) == 0 or (
self._is_dataframe and self._query_compiler.get_axis_len(1) == 0
):
return pandas.DataFrame(
index=self.index,
columns=self.columns if self._is_dataframe else None,
Expand Down
26 changes: 18 additions & 8 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def __repr__(self) -> str:
str
"""
num_rows = pandas.get_option("display.max_rows") or len(self)
num_cols = pandas.get_option("display.max_columns") or self._query_compiler.get_axis_len(1)
num_cols = pandas.get_option(
"display.max_columns"
) or self._query_compiler.get_axis_len(1)
result = repr(self._build_repr_df(num_rows, num_cols))
if len(self) > num_rows or self._query_compiler.get_axis_len(1) > num_cols:
# The split here is so that we don't repr pandas row lengths.
Expand Down Expand Up @@ -297,9 +299,7 @@ def _repr_html_(self) -> str: # pragma: no cover
# We split so that we insert our correct dataframe dimensions.
return result.split("<p>")[
0
] + "<p>{0} rows x {1} columns</p>\n</div>".format(
*self.shape
)
] + "<p>{0} rows x {1} columns</p>\n</div>".format(*self.shape)
else:
return result

Expand Down Expand Up @@ -781,7 +781,9 @@ def dot(self, other) -> Union[DataFrame, Series]: # noqa: PR01, RT01, D200
"""
if isinstance(other, BasePandasDataset):
common = self.columns.union(other.index)
if len(common) > self._query_compiler.get_axis_len(1) or len(common) > len(other.index):
if len(common) > self._query_compiler.get_axis_len(1) or len(common) > len(
other.index
):
raise ValueError("Matrices are not aligned")

qc = other.reindex(index=common)._query_compiler
Expand Down Expand Up @@ -1119,7 +1121,11 @@ def insert(
)
if allow_duplicates is not True and column in self.columns:
raise ValueError(f"cannot insert {column}, already exists")
if not -self._query_compiler.get_axis_len(1) <= loc <= self._query_compiler.get_axis_len(1):
if (
not -self._query_compiler.get_axis_len(1)
<= loc
<= self._query_compiler.get_axis_len(1)
):
raise IndexError(
f"index {loc} is out of bounds for axis 0 with size {self._query_compiler.get_axis_len(1)}"
)
Expand Down Expand Up @@ -2074,7 +2080,9 @@ def squeeze(
Squeeze 1 dimensional axis objects into scalars.
"""
axis = self._get_axis_number(axis) if axis is not None else None
if axis is None and (self._query_compiler.get_axis_len(1) == 1 or len(self) == 1):
if axis is None and (
self._query_compiler.get_axis_len(1) == 1 or len(self) == 1
):
return Series(query_compiler=self._query_compiler).squeeze()
if axis == 1 and self._query_compiler.get_axis_len(1) == 1:
self._query_compiler._shape_hint = "column"
Expand Down Expand Up @@ -2680,7 +2688,9 @@ def __setitem__(self, key, value) -> None:
self.columns = prev_index.insert(0, key)
return
# Do new column assignment after error checks and possible value modifications
self.insert(loc=self._query_compiler.get_axis_len(1), column=key, value=value)
self.insert(
loc=self._query_compiler.get_axis_len(1), column=key, value=value
)
return

if not hashable(key):
Expand Down

0 comments on commit 40cf94e

Please sign in to comment.