Skip to content

CLN clean ups in code #36570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 7, 2020
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ def _add_timedelta_arraylike(self, other):
self_i8, other_i8, arr_mask=self._isnan, b_mask=other._isnan
)
if self._hasnans or other._hasnans:
mask = (self._isnan) | (other._isnan)
mask = self._isnan | other._isnan
new_values[mask] = iNaT

return type(self)(new_values, dtype=self.dtype)
Expand Down
1 change: 1 addition & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,7 @@ def objects_to_datetime64ns(
utc : bool, default False
Whether to convert timezone-aware timestamps to UTC.
errors : {'raise', 'ignore', 'coerce'}
require_iso8601 : bool, default False
allow_object : bool
Whether to return an object-dtype ndarray instead of raising if the
data contains more than one timezone.
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
),
)
)
def from_tuples(cls, data, closed="right", copy=False, dtype=None):
def from_tuples(cls, data, closed="right", dtype=None):
if len(data):
left, right = [], []
else:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def _sub_period_array(self, other):

new_values = np.array([self.freq.base * x for x in new_values])
if self._hasnans or other._hasnans:
mask = (self._isnan) | (other._isnan)
mask = self._isnan | other._isnan
new_values[mask] = NaT
return new_values

Expand Down
8 changes: 4 additions & 4 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def from_spmatrix(cls, data):

return cls._simple_new(arr, index, dtype)

def __array__(self, dtype=None, copy=True) -> np.ndarray:
def __array__(self, dtype=None) -> np.ndarray:
fill_value = self.fill_value

if self.sp_index.ngaps == 0:
Expand Down Expand Up @@ -1161,9 +1161,9 @@ def __setstate__(self, state):

def nonzero(self):
if self.fill_value == 0:
return (self.sp_index.to_int_index().indices,)
return self.sp_index.to_int_index().indices
else:
return (self.sp_index.to_int_index().indices[self.sp_values != 0],)
return self.sp_index.to_int_index().indices[self.sp_values != 0]

# ------------------------------------------------------------------------
# Reductions
Expand Down Expand Up @@ -1515,7 +1515,7 @@ def _formatter(self, boxed=False):
SparseArray._add_unary_ops()


def make_sparse(arr: np.ndarray, kind="block", fill_value=None, dtype=None, copy=False):
def make_sparse(arr: np.ndarray, kind="block", fill_value=None, dtype=None):
"""
Convert ndarray to sparse format

Expand Down
1 change: 1 addition & 0 deletions pandas/core/computation/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def tokenize_backtick_quoted_string(
The token that represents the backtick quoted string.
The integer is equal to BACKTICK_QUOTED_STRING (100).
"""
string_end = None
for _, tokval, start, _, _ in token_generator:
if tokval == "`":
string_end = start[1]
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def pr(left, right):
res = pr(left.value, right.prune(klass))
elif not (is_term(left) or is_term(right)):
res = pr(left.prune(klass), right.prune(klass))
else:
res = None

return res

Expand Down Expand Up @@ -445,7 +447,7 @@ def visit_Attribute(self, node, **kwargs):
# try to get the value to see if we are another expression
try:
resolved = resolved.value
except (AttributeError):
except AttributeError:
pass

try:
Expand Down