Skip to content

Commit

Permalink
Fixes Bears-R-Us#2627: Failures with flake8 6.1.0 (Bears-R-Us#2628)
Browse files Browse the repository at this point in the history
This PR fixes Bears-R-Us#2627.

flake8 latest version, 6.1.0, was release on 7/29. This version update was casuing the CI to fail on master. This adds the changes needed for arkouda to pass the lastes version of flake8.

We should all be sure to update our conda env to have the latest version. For me the easiest way to do this was to blow away the old env and recreate from the yaml file. It might be necessarry to update your conda channels

Co-authored-by: Pierce Hayes <[email protected]>
  • Loading branch information
stress-tess and Pierce Hayes authored Aug 1, 2023
1 parent c8f2a3b commit 201dd11
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion arkouda/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def find(query, space):

# Concatenate the space and query in fast (block interleaved) mode
if isinstance(query, (pdarray, Strings, Categorical)):
if type(query) != type(space):
if type(query) is not type(space):
raise TypeError("Arguments must have same type")
c = concatenate((space, query), ordered=False)
spacesize = space.size
Expand Down
2 changes: 1 addition & 1 deletion arkouda/client_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def ip_address(values):
for importing Python lists of IP addresses into Arkouda.
"""

if type(values) == IPv4:
if isinstance(values, IPv4):
return values

if isinstance(values, pdarray):
Expand Down
14 changes: 7 additions & 7 deletions arkouda/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def __init__(self, initialdata=None, index=None):
sizes = set()

# Initial data is a dictionary of arkouda arrays
if type(initialdata) == dict:
if isinstance(initialdata, dict):
for key, val in initialdata.items():
if not isinstance(val, self.COLUMN_CLASSES):
raise ValueError(f"Values must be one of {self.COLUMN_CLASSES}.")
Expand All @@ -319,7 +319,7 @@ def __init__(self, initialdata=None, index=None):
self._columns.append(key)

# Initial data is a list of arkouda arrays
elif type(initialdata) == list:
elif isinstance(initialdata, list):
# Create string IDs for the columns
keys = [str(x) for x in range(len(initialdata))]
for key, col in zip(keys, initialdata):
Expand Down Expand Up @@ -394,7 +394,7 @@ def __getitem__(self, key):
return result
if len({type(x) for x in key}) > 1:
raise TypeError("Invalid selector: too many types in list.")
if type(key[0]) == str:
if isinstance(key[0], str):
for k in key:
result.data[k] = UserDict.__getitem__(self, k)
result._columns.append(k)
Expand Down Expand Up @@ -441,7 +441,7 @@ def __setitem__(self, key, value):
add_index = True

# Set a single row in the dataframe using a dict of values
if type(key) == int:
if isinstance(key, int):
for k in self._columns:
if isinstance(self.data[k], Strings):
raise ValueError(
Expand All @@ -463,7 +463,7 @@ def __setitem__(self, key, value):
self[k][key] = v

# Set a single column in the dataframe using a an arkouda array
elif type(key) == str:
elif isinstance(key, str):
if not isinstance(value, self.COLUMN_CLASSES):
raise ValueError(f"Column must be one of {self.COLUMN_CLASSES}.")
elif self._size is not None and self._size != value.size:
Expand Down Expand Up @@ -1046,12 +1046,12 @@ def _rename_index(self, mapper: Union[Callable, Dict], inplace: bool = False) ->
for i in range(obj.index.size):
oldval = obj.index[i]
newval = mapper(oldval)
if type(oldval) != type(newval):
if type(oldval) is not type(newval):
raise TypeError("Replacement value must have the same type as the original value")
obj.index.values[obj.index.values == oldval] = newval
elif isinstance(mapper, dict):
for key, val in mapper.items():
if type(key) != type(val):
if type(key) is not type(val):
raise TypeError("Replacement value must have the same type as the original value")
obj.index.values[obj.index.values == key] = val
else:
Expand Down
4 changes: 2 additions & 2 deletions arkouda/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ def to_dict(self, label):
data = {}
if label is None:
label = "idx"
elif type(label) == list:
elif isinstance(label, list):
label = label[0]
data[label] = self.index
return data

def _check_types(self, other):
if type(self) != type(other):
if type(self) is not type(other):
raise TypeError("Index Types must match")

def _merge(self, other):
Expand Down
2 changes: 1 addition & 1 deletion arkouda/pdarrayclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def _binop(self, other: pdarray, op: str) -> pdarray:
"""
# For pdarray subclasses like ak.Datetime and ak.Timedelta, defer to child logic
if type(other) != pdarray and issubclass(type(other), pdarray):
if type(other) is not pdarray and issubclass(type(other), pdarray):
return NotImplemented
if op not in self.BinOps:
raise ValueError(f"bad operator {op}")
Expand Down
9 changes: 5 additions & 4 deletions arkouda/pdarraysetops.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def _in1d_single(
"""
from arkouda.categorical import Categorical as Categorical_
from arkouda.dtypes import bool as ak_bool

if isinstance(pda1, pdarray) or isinstance(pda1, Strings) or isinstance(pda1, Categorical_):
# While isinstance(thing, type) can be called on a tuple of types,
# this causes an issue with mypy for unknown reasons.
Expand Down Expand Up @@ -437,7 +438,7 @@ def union1d(
if (
isinstance(pda1, (pdarray, Strings, Categorical_))
and isinstance(pda2, (pdarray, Strings, Categorical_))
and type(pda1) == type(pda2)
and type(pda1) is type(pda2)
):
if pda1.size == 0:
return pda2 # union is pda2
Expand Down Expand Up @@ -532,7 +533,7 @@ def intersect1d(
if (
isinstance(pda1, (pdarray, Strings, Categorical_))
and isinstance(pda2, (pdarray, Strings, Categorical_))
and type(pda1) == type(pda2)
and type(pda1) is type(pda2)
):
if pda1.size == 0:
return pda1 # nothing in the intersection
Expand Down Expand Up @@ -650,7 +651,7 @@ def setdiff1d(
if (
isinstance(pda1, (pdarray, Strings, Categorical_))
and isinstance(pda2, (pdarray, Strings, Categorical_))
and type(pda1) == type(pda2)
and type(pda1) is type(pda2)
):
if pda1.size == 0:
return pda1 # return a zero length pdarray
Expand Down Expand Up @@ -761,7 +762,7 @@ def setxor1d(pda1: groupable, pda2: groupable, assume_unique: bool = False) -> U
if (
isinstance(pda1, (pdarray, Strings, Categorical_))
and isinstance(pda2, (pdarray, Strings, Categorical_))
and type(pda1) == type(pda2)
and type(pda1) is type(pda2)
):
if pda1.size == 0:
return pda2 # return other pdarray if pda1 is empty
Expand Down
2 changes: 1 addition & 1 deletion arkouda/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_callback(x):
return type(x)
elif hasattr(x, "_cast"):
return x._cast
elif type(x) == BitVector:
elif isinstance(x, BitVector):
return BitVectorizer(width=x.width, reverse=x.reverse)
else:
return identity
Expand Down

0 comments on commit 201dd11

Please sign in to comment.