Skip to content

CLN: more lgtm.com cleanups #30259

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 1 commit into from
Dec 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pandas/core/arrays/_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ def _generate_range_overflow_safe_signed(
# watch out for very special case in which we just slightly
# exceed implementation bounds, but when passing the result to
# np.arange will get a result slightly within the bounds
assert endpoint >= 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see how this is redundant given L176 and L178, but it doesn't seem harmful

result = np.uint64(endpoint) + np.uint64(addend)
i64max = np.uint64(np.iinfo(np.int64).max)
assert result > i64max
Expand Down
20 changes: 1 addition & 19 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ def _aggregate(self, arg, *args, **kwargs):
None if not required
"""
is_aggregator = lambda x: isinstance(x, (list, tuple, dict))
is_nested_renamer = False

_axis = kwargs.pop("_axis", None)
if _axis is None:
Expand Down Expand Up @@ -398,24 +397,7 @@ def _agg(arg, func):
keys = list(arg.keys())
result = OrderedDict()

# nested renamer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i guess this was previously used, ok.

if is_nested_renamer:
result = list(_agg(arg, _agg_1dim).values())

if all(isinstance(r, dict) for r in result):

result, results = OrderedDict(), result
for r in results:
result.update(r)
keys = list(result.keys())

else:

if self._selection is not None:
keys = None

# some selection on the object
elif self._selection is not None:
if self._selection is not None:

sl = set(self._selection_list)

Expand Down
5 changes: 0 additions & 5 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,6 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
obj = self._obj_with_exclusions
result: OrderedDict = OrderedDict()
cannot_agg = []
errors = None
for item in obj:
data = obj[item]
colg = SeriesGroupBy(data, selection=item, grouper=self.grouper)
Expand All @@ -1157,10 +1156,6 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
if cannot_agg:
result_columns = result_columns.drop(cannot_agg)

# GH6337
if not len(result_columns) and errors is not None:
raise errors

return DataFrame(result, columns=result_columns)

def _wrap_applied_output(self, keys, values, not_indexed_same=False):
Expand Down
3 changes: 0 additions & 3 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2204,9 +2204,6 @@ def reorder_levels(self, order):
levels=new_levels, codes=new_codes, names=new_names, verify_integrity=False
)

def __getslice__(self, i, j):
return self.__getitem__(slice(i, j))

def _get_codes_for_sorting(self):
"""
we categorizing our codes by using the
Expand Down
1 change: 0 additions & 1 deletion pandas/core/internals/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def get_reindexed_values(self, empty_dtype, upcasted_na):
return array(
np.full(self.shape[1], fill_value.value), dtype=empty_dtype
)
pass
elif getattr(self.block, "is_categorical", False):
pass
elif getattr(self.block, "is_extension", False):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/ops/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def dispatch_fill_zeros(op, left, right, result):
# Note: no need to do this for truediv; in py3 numpy behaves the way
# we want.
result = mask_zero_div_zero(left, right, result)
elif op is op is rfloordiv:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is definitiely wrong as is, but is it currently parsed as elif op is (op is rfloordiv): in which case it would also evaluate to False? If so, there may be a bug hidden in here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't seem to find a bug here. This code must work!

>>> def rfloordiv(left, right):
...     return right // left
...
>>> op = rfloordiv
>>>
>>> op is op is rfloordiv
True
>>>
>>> op is (op is rfloordiv)
False
>>>
>>> (op is op) is rfloordiv
False
>>>
>>> op is rfloordiv
True
>>>
>>> 1 is 1 is 1
True
>>>
>>> (1 is 1) is 1
False
>>>
>>> 1 is (1 is 1)
False
>>>

elif op is rfloordiv:
# Note: no need to do this for rtruediv; in py3 numpy behaves the way
# we want.
result = mask_zero_div_zero(right, left, result)
Expand Down
4 changes: 2 additions & 2 deletions pandas/plotting/_matplotlib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,12 @@ def __call__(self):
except ValueError:
return []

if dmin > dmax:
dmax, dmin = dmin, dmax
# We need to cap at the endpoints of valid datetime

# FIXME: dont leave commented-out
# TODO(wesm) unused?
# if dmin > dmax:
# dmax, dmin = dmin, dmax
# delta = relativedelta(dmax, dmin)
# try:
# start = dmin - delta
Expand Down
5 changes: 2 additions & 3 deletions scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def header(title, width=80, char="#"):
"]{text}\n"
)
else:
raise ValueError('Unknown output_format "{}"'.format(output_format))
raise ValueError(f'Unknown output_format "{output_format}"')

output = ""
for name, res in result.items():
Expand All @@ -977,11 +977,10 @@ def header(title, width=80, char="#"):
continue
exit_status += 1
output += output_format.format(
name=name,
path=res["file"],
row=res["file_line"],
code=err_code,
text="{}: {}".format(name, err_desc),
text=f"{name}: {err_desc}",
)

sys.stdout.write(output)
Expand Down