From f516dfa150e0524c357bff7357020f48221f6dc0 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 10 Feb 2022 17:21:33 -0800 Subject: [PATCH] Invert logic to use reflect instead of not_reflect boolean. --- python/cudf/cudf/core/series.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 135e8e559d2..ddaa358e9d9 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -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 @@ -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