cudf icon indicating copy to clipboard operation
cudf copied to clipboard

[BUG] Reverse binary ops between cudf.Scalar and base types not working.

Open bdice opened this issue 3 years ago • 1 comments

Describe the bug Binary operations don't work between base types (int) and cudf.Scalar when the reverse operator dispatch is called, like __radd__ or __rpow__.

Steps/Code to reproduce bug

>>> import cudf
>>> cudf.Scalar(3) + 1
Scalar(4, dtype=int64)
>>> 1 + cudf.Scalar(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../cudf/python/cudf/cudf/core/mixins/mixin_factory.py", line 11, in wrapper
    return method(self, *args1, *args2, **kwargs1, **kwargs2)
  File ".../cudf/python/cudf/cudf/core/scalar.py", line 276, in _binaryop
    out_dtype = self._binop_result_dtype_or_error(other, op)
  File ".../cudf/python/cudf/cudf/core/scalar.py", line 246, in _binop_result_dtype_or_error
    out_dtype = get_allowed_combinations_for_operator(
  File ".../cudf/python/cudf/cudf/utils/dtypes.py", line 489, in get_allowed_combinations_for_operator
    ltype, rtype, outtype = valid_combo
ValueError: not enough values to unpack (expected 3, got 1)

Expected behavior Forward and reverse binary operations should dispatch in the same way. In this case, it seems that reverse operators are not being properly remapped to "forward" operators when looking up the dispatchable NumPy types in get_allowed_combinations_for_operator.

This is blocking some tests for #11025. If that PR is merged before this is fixed, the affected tests should be uncommented when fixing this issue.

Environment overview (please complete the following information) Tested on commit bad00d7e8f7d203dbaff8f3e9548821d8c074255 on branch-22.08. Built from source.

bdice avatar Jul 08 '22 05:07 bdice

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] avatar Aug 07 '22 06:08 github-actions[bot]