From 3731b4c6679172aedbfdf47934d57ab79bf4f64e Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Thu, 29 Sep 2022 16:39:41 +0100 Subject: [PATCH] Fix `is_valid` checks in `Scalar._binaryop` (#11818) We need to actually call the method otherwise we will get false positives for validity of the operands. Fortunately, this seems to have been a benign bug since the host pandas `NAType` handles all of the operations appropriately, so the code was "working" before, but the logic was incorrect. Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/11818 --- python/cudf/cudf/core/scalar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/scalar.py b/python/cudf/cudf/core/scalar.py index 5147cd626fe..e05e8662fe4 100644 --- a/python/cudf/cudf/core/scalar.py +++ b/python/cudf/cudf/core/scalar.py @@ -340,8 +340,8 @@ def _binaryop(self, other, op: str): if is_scalar(other): other = to_cudf_compatible_scalar(other) out_dtype = self._binop_result_dtype_or_error(other, op) - valid = self.is_valid and ( - isinstance(other, np.generic) or other.is_valid + valid = self.is_valid() and ( + isinstance(other, np.generic) or other.is_valid() ) if not valid: return Scalar(None, dtype=out_dtype)