Skip to content

Commit

Permalink
FIX-#6427: make code compatible with flake8==6.1.0 (#6428)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored and RehanSD committed Aug 22, 2023
1 parent 6114542 commit 7b23559
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion modin/core/dataframe/algebra/default2pandas/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def register(cls, func, obj_type=None, inplace=None, fn_name=None):
else:
fn = func

if type(fn) == property:
if type(fn) is property:
fn = cls.build_property_wrapper(fn)

def applyier(df, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion modin/core/dataframe/algebra/default2pandas/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def fn(df, resample_kwargs, *args, **kwargs):
df = df.squeeze(axis=1)
resampler = df.resample(**resample_kwargs)

if type(func) == property:
if type(func) is property:
return func.fget(resampler)

return func(resampler, *args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions modin/core/dataframe/algebra/default2pandas/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fn(df, rolling_kwargs, *args, **kwargs):
"""Create rolling window for the passed frame and execute specified `func` on it."""
roller = df.rolling(**rolling_kwargs)

if type(func) == property:
if type(func) is property:
return func.fget(roller)

return func(roller, *args, **kwargs)
Expand Down Expand Up @@ -100,7 +100,7 @@ def fn(df, rolling_args, *args, **kwargs):
df = df.squeeze(axis=1)
roller = df.expanding(*rolling_args)

if type(func) == property:
if type(func) is property:
return func.fget(roller)

return func(roller, *args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion modin/core/dataframe/pandas/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3852,7 +3852,7 @@ def from_dataframe(cls, df: "ProtocolDataframe") -> "PandasDataframe":
PandasDataframe
A new Core Modin Dataframe object.
"""
if type(df) == cls:
if type(df) is cls:
return df

if not hasattr(df, "__dataframe__"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def _get_data_buffer(

# TODO: this for-loop is slow; can be implemented in Cython/C/C++ later
for i in range(buf.size):
if type(buf[i]) == str:
if type(buf[i]) is str:
b.extend(buf[i].encode(encoding="utf-8"))

# Convert the byte array to a pandas "buffer" using a NumPy array as the backing store
Expand Down Expand Up @@ -413,7 +413,7 @@ def _get_validity_buffer(self) -> Tuple[PandasProtocolBuffer, Any]:
# Determine the encoding for valid values
valid = 1 if invalid == 0 else 0

mask = [valid if type(buf[i]) == str else invalid for i in range(buf.size)]
mask = [valid if type(buf[i]) is str else invalid for i in range(buf.size)]

# Convert the mask array to a Pandas "buffer" using a NumPy array as the backing store
buffer = PandasProtocolBuffer(np.asarray(mask, dtype="uint8"))
Expand Down Expand Up @@ -459,7 +459,7 @@ def _get_offsets_buffer(self) -> Tuple[PandasProtocolBuffer, Any]:
offsets = [ptr] + [None] * len(values)
for i, v in enumerate(values):
# For missing values (in this case, `np.nan` values), we don't increment the pointer)
if type(v) == str:
if type(v) is str:
b = v.encode(encoding="utf-8")
ptr += len(b)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _get_unsupported_cols(cls, obj):
# The TypeError could be raised when converting a sparse data to
# arrow table - https://github.com/apache/arrow/pull/4497. If this
# is the case - fall back to pandas, otherwise - rethrow the error.
if type(err) == TypeError:
if type(err) is TypeError:
if any([isinstance(t, pandas.SparseDtype) for t in obj.dtypes]):
ErrorMessage.single_warning(
"Sparse data is not currently supported!"
Expand All @@ -187,7 +187,7 @@ def _get_unsupported_cols(cls, obj):
# We catch and handle this error here. If there are no duplicates
# (is_unique is True), then the error is caused by something different
# and we just rethrow it.
if (type(err) == ValueError) and obj.columns.is_unique:
if (type(err) is ValueError) and obj.columns.is_unique:
raise err

regex = r"Conversion failed for column ([^\W]*)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ def test_dict(self):
assert str(mdt) == str(pdt)

# Make sure the lazy proxy dtype is not materialized yet.
assert type(mdt) != pandas.CategoricalDtype
assert type(mdt) is not pandas.CategoricalDtype
assert mdt._parent is not None
assert mdt._update_proxy(at, at.column(0)._name) is mdt
assert mdt._update_proxy(at, at.column(2)._name) is not mdt
Expand Down
2 changes: 1 addition & 1 deletion modin/experimental/core/io/text/csv_glob_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def partitioned_file(
-----
The logic gets really complicated if we try to use the `TextFileDispatcher.partitioned_file`.
"""
if type(files) != list:
if type(files) is not list:
files = [files]

if num_partitions is None:
Expand Down
2 changes: 1 addition & 1 deletion modin/numpy/test/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,5 @@ def test__array__():
modin_arr = np.array(numpy_arr)
# this implicitly calls `__array__`
converted_array = numpy.array(modin_arr)
assert type(converted_array) == type(numpy_arr)
assert type(converted_array) is type(numpy_arr)
assert_scalar_or_array_equal(converted_array, numpy_arr)
2 changes: 1 addition & 1 deletion modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def equals(self, other): # noqa: PR01, RT01, D200
other = self.__constructor__(other)

if (
type(self) != type(other)
type(self) is not type(other)
or not self.index.equals(other.index)
or not self.columns.equals(other.columns)
):
Expand Down
2 changes: 1 addition & 1 deletion modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs)

if relabeling_required:

def do_relabel(obj_to_relabel):
def do_relabel(obj_to_relabel): # noqa: F811
new_order, new_columns_idx = order, pandas.Index(new_columns)
if not self._as_index:
nby_cols = len(obj_to_relabel.columns) - len(new_columns_idx)
Expand Down
2 changes: 1 addition & 1 deletion modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ def equals(self, other): # noqa: PR01, RT01, D200
# Copy into a Modin Series to simplify logic below
other = self.__constructor__(other)

if type(self) != type(other) or not self.index.equals(other.index):
if type(self) is not type(other) or not self.index.equals(other.index):
return False

old_name_self = self.name
Expand Down
2 changes: 1 addition & 1 deletion modin/pandas/test/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2276,7 +2276,7 @@ def test_validate_by():
"""Test ``modin.core.dataframe.algebra.default2pandas.groupby.GroupBy.validate_by``."""

def compare(obj1, obj2):
assert type(obj1) == type(
assert type(obj1) is type(
obj2
), f"Both objects must be instances of the same type: {type(obj1)} != {type(obj2)}."
if isinstance(obj1, list):
Expand Down
2 changes: 1 addition & 1 deletion modin/pandas/test/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_to_list(data):
modin_series, pandas_series = create_test_series(data)
pd_res = pandas_series.to_list()
md_res = modin_series.to_list()
assert type(pd_res) == type(md_res)
assert type(pd_res) is type(md_res)
assert np.array_equal(pd_res, md_res, equal_nan=True)


Expand Down
2 changes: 1 addition & 1 deletion modin/pandas/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def assert_empty_frame_equal(df1, df2):

if (df1.empty and not df2.empty) or (df2.empty and not df1.empty):
assert False, "One of the passed frames is empty, when other isn't"
elif df1.empty and df2.empty and type(df1) != type(df2):
elif df1.empty and df2.empty and type(df1) is not type(df2):
assert False, f"Empty frames have different types: {type(df1)} != {type(df2)}"


Expand Down

0 comments on commit 7b23559

Please sign in to comment.