Skip to content

Commit

Permalink
Error gracefully on attempts to perform bitwise binops with extension…
Browse files Browse the repository at this point in the history
… dtypes.
  • Loading branch information
vyasr committed May 5, 2021
1 parent 15e9458 commit a930a11
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3630,8 +3630,15 @@ def _normalize_binop_value(self, other):

def _bitwise_binop(self, other, op):
"""Type-coercing wrapper around _binaryop for bitwise operations."""
self_is_bool = np.issubdtype(self.dtype, np.bool_)
other_is_bool = np.issubdtype(other.dtype, np.bool_)
# This will catch attempts at bitwise ops on extension dtypes.
try:
self_is_bool = np.issubdtype(self.dtype, np.bool_)
other_is_bool = np.issubdtype(other.dtype, np.bool_)
except TypeError:
raise TypeError(
f"Operation 'bitwise {op}' not supported between "
f"{self.dtype.type.__name__} and {other.dtype.type.__name__}"
)

if (self_is_bool or np.issubdtype(self.dtype, np.integer)) and (
other_is_bool or np.issubdtype(other.dtype, np.integer)
Expand Down

0 comments on commit a930a11

Please sign in to comment.