You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type promotion to handle division by zero in __floordiv__ or __mod__ is inconsistently applied if the 0 is already a cudf.Scalar, depending on whether the dtypes of the Scalar and the divided Column match.
Steps/Code to reproduce bug
importcudfs=cudf.Series([1, 2], dtype="int64")
print(s//0)
# 0 inf# 1 inf# dtype: float64print(s//cudf.Scalar(0, dtype="int32"))
# 0 inf# 1 inf# dtype: float64print(s//cudf.Scalar(0)) # equivalent to cudf.Scalar(0, dtype="int64")# 0 9223372036854775807# 1 9223372036854775807# dtype: int64# Technically worse than this, since I think we end up # with division by zero of signed integer types in libcudf# which is UB
Expected behavior
I should always get promotion to float64 (does it need to be float64?) and then inf in the output.
Why does this happen?
NumericalColumn._binaryop checks for division by zero if the op is __mod__ or __floordiv__, but doesn't handle the case where other is a cudf.Scalar. NumericalColumn._wrap_binop_normalization hands back a cudf.Scalar if it is passed a Scalar with the same dtype as the column in question. So in this case, we don't check to see if we have a zero and don't promote to float.
The text was updated successfully, but these errors were encountered:
Further inconsistency, is that pandas special-cases bool dtypes and raises NotImplementedError or ZeroDivisionError (depending on ???) for division of a bool series by a bool.
And is inconsistent in its handling of division by a scalar boolean and a series with booleans.
Further inconsistency, is that pandas special-cases bool dtypes and raises NotImplementedError or ZeroDivisionError (depending on ???) for division of a bool series by a bool.
And is inconsistent in its handling of division by a scalar boolean and a series with booleans.
Describe the bug
Type promotion to handle division by zero in
__floordiv__
or__mod__
is inconsistently applied if the0
is already acudf.Scalar
, depending on whether the dtypes of theScalar
and the dividedColumn
match.Steps/Code to reproduce bug
Expected behavior
I should always get promotion to
float64
(does it need to befloat64
?) and theninf
in the output.Why does this happen?
NumericalColumn._binaryop
checks for division by zero if the op is__mod__
or__floordiv__
, but doesn't handle the case whereother
is acudf.Scalar
.NumericalColumn._wrap_binop_normalization
hands back acudf.Scalar
if it is passed aScalar
with the same dtype as the column in question. So in this case, we don't check to see if we have a zero and don't promote to float.The text was updated successfully, but these errors were encountered: