Skip to content
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

Explicitly pass .dtype into is_foo_dtype functions #14657

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/_internals/where.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _check_and_cast_columns_with_other(
other = cudf.Scalar(other)

if is_mixed_with_object_dtype(other, source_col) or (
is_bool_dtype(source_col) and not is_bool_dtype(common_dtype)
is_bool_dtype(source_dtype) and not is_bool_dtype(common_dtype)
):
raise TypeError(mixed_err)

Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/column/numerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase:
out_dtype = "bool"

if op in {"__and__", "__or__", "__xor__"}:
if is_float_dtype(self.dtype) or is_float_dtype(other):
if is_float_dtype(self.dtype) or is_float_dtype(other.dtype):
raise TypeError(
f"Operation 'bitwise {op[2:-2]}' not supported between "
f"{self.dtype.type.__name__} and "
f"{other.dtype.type.__name__}"
)
if is_bool_dtype(self.dtype) or is_bool_dtype(other):
if is_bool_dtype(self.dtype) or is_bool_dtype(other.dtype):
out_dtype = "bool"

if (
Expand Down
6 changes: 3 additions & 3 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def _getitem_tuple_arg(self, arg):
tmp_arg[1],
)

if is_bool_dtype(tmp_arg[0]):
if is_bool_dtype(tmp_arg[0].dtype):
df = columns_df._apply_boolean_mask(
BooleanMask(tmp_arg[0], len(columns_df))
)
Expand Down Expand Up @@ -6029,7 +6029,7 @@ def _reduce(
numeric_cols = (
name
for name in self._data.names
if is_numeric_dtype(self._data[name])
if is_numeric_dtype(self._data[name].dtype)
)
source = self._get_columns_by_label(numeric_cols)
if source.empty:
Expand Down Expand Up @@ -6075,7 +6075,7 @@ def _reduce(
numeric_cols = (
name
for name in self._data.names
if is_numeric_dtype(self._data[name])
if is_numeric_dtype(self._data[name].dtype)
)
source = self._get_columns_by_label(numeric_cols)
if source.empty:
Expand Down
10 changes: 7 additions & 3 deletions python/cudf/cudf/testing/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ def assert_column_equal(
elif not (
(
not dtype_can_compare_equal_to_other(left.dtype)
and is_numeric_dtype(right)
and is_numeric_dtype(right.dtype)
)
or (
is_numeric_dtype(left)
is_numeric_dtype(left.dtype)
and not dtype_can_compare_equal_to_other(right.dtype)
)
):
Expand All @@ -245,7 +245,11 @@ def assert_column_equal(
left.isnull().values == right.isnull().values
)

if columns_equal and not check_exact and is_numeric_dtype(left):
if (
columns_equal
and not check_exact
and is_numeric_dtype(left.dtype)
):
# non-null values must be the same
columns_equal = cp.allclose(
left.apply_boolean_mask(
Expand Down