Skip to content

CLN: Remove incorrect check, comment, rename #27922

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 10 commits into from
Aug 20, 2019
15 changes: 5 additions & 10 deletions pandas/core/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,6 @@ def wrapper(self, other, axis=None):

if isinstance(other, ABCSeries) and not self._indexed_same(other):
raise ValueError("Can only compare identically-labeled Series objects")
elif (
is_list_like(other)
and len(other) != len(self)
and not isinstance(other, (set, frozenset))
):
raise ValueError("Lengths must match")

elif isinstance(other, (np.ndarray, ABCIndexClass, ABCSeries)):
# TODO: make this treatment consistent across ops and classes.
# We are not catching all listlikes here (e.g. frozenset, tuple)
Expand Down Expand Up @@ -888,9 +881,11 @@ def wrapper(self, other, axis=None):
)

result = self._constructor(res_values, index=self.index)
# rename is needed in case res_name is None and result.name
# is not.
return finalizer(result).rename(res_name)
result = finalizer(result)

# pin name for case res_name is None and result.name is not.
Copy link
Member

Choose a reason for hiding this comment

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

this comment is still not correct I think. As far as I know, result.name will always be None?
As mentioned in the original PR (https://github.com/pandas-dev/pandas/pull/27803/files#r311961558), I think it is here about self.name not being None.

The problem we were trying to solve is that finalize will put back the original name, which might be wrong. So that's the reason we can't pass res_name into _constructor and afterwards do finalize, as that might change the name again.

result.name = res_name
return result

wrapper.__name__ = op_name
return wrapper
Expand Down