Skip to content

Commit

Permalink
Invert logic to use reflect instead of not_reflect boolean.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Feb 11, 2022
1 parent c850aee commit f516dfa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,8 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
# First look for methods of the class.
fname = ufunc.__name__
if fname in binary_operations:
not_reflect = self is inputs[0]
other = inputs[not_reflect]
reflect = self is not inputs[0]
other = inputs[0] if reflect else inputs[1]

# These operators need to be mapped to their inverses when
# performing a reflected operation because no reflected version of
Expand All @@ -1009,16 +1009,16 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
"ge": "le",
"lt": "gt",
"le": "ge",
# ne and eq are symmetric
# ne and eq are symmetric, so they are their own inverse op
"ne": "ne",
"eq": "eq",
}

op = binary_operations[fname]
if op in ops_without_reflection and not not_reflect:
if reflect and op in ops_without_reflection:
op = ops_without_reflection[op]
not_reflect = True
op = f"__{'' if not_reflect else 'r'}{op}__"
reflect = False
op = f"__{'r' if reflect else ''}{op}__"

# pandas bitwise operations return bools if indexes are misaligned.
# TODO: Generalize for other types of Frames
Expand Down

0 comments on commit f516dfa

Please sign in to comment.