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

[BUG] Binary ops fail unexpectedly for Decimal inputs #11636

Closed
bdice opened this issue Aug 31, 2022 · 1 comment · Fixed by #12142
Closed

[BUG] Binary ops fail unexpectedly for Decimal inputs #11636

bdice opened this issue Aug 31, 2022 · 1 comment · Fixed by #12142
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@bdice
Copy link
Contributor

bdice commented Aug 31, 2022

Describe the bug
cuDF 22.08 raises an UnboundLocalError without much helpful context when attempting to compute certain operators like __pow__ or __floordiv__ on decimal columns.

Steps/Code to reproduce bug

>>> from decimal import Decimal
>>> import cudf
>>> cudf.Series([Decimal("3.")]) ** 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bdice/mambaforge/envs/rapids-22.08/lib/python3.9/site-packages/cudf/core/mixins/mixin_factory.py", line 11, in wrapper
    return method(self, *args1, *args2, **kwargs1, **kwargs2)
  File "/home/bdice/mambaforge/envs/rapids-22.08/lib/python3.9/site-packages/cudf/core/indexed_frame.py", line 2984, in _binaryop
    ColumnAccessor(type(self)._colwise_binop(operands, op)),
  File "/home/bdice/mambaforge/envs/rapids-22.08/lib/python3.9/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/bdice/mambaforge/envs/rapids-22.08/lib/python3.9/site-packages/cudf/core/frame.py", line 1707, in _colwise_binop
    else getattr(operator, fn)(left_column, right_column)
  File "/home/bdice/mambaforge/envs/rapids-22.08/lib/python3.9/site-packages/cudf/core/mixins/mixin_factory.py", line 11, in wrapper
    return method(self, *args1, *args2, **kwargs1, **kwargs2)
  File "/home/bdice/mambaforge/envs/rapids-22.08/lib/python3.9/site-packages/cudf/core/column/decimal.py", line 107, in _binaryop
    return result
UnboundLocalError: local variable 'result' referenced before assignment

Expected behavior
Either the operation will be computed successfully OR a helpful/informative error message is shown. The UnboundLocalError is indicative of a bug in the cuDF Python code but not necessarily an indication of whether libcudf can perform the requested computation.

Environment overview (please complete the following information)

  • Environment location: Bare-metal
  • Method of cuDF install: conda

Additional context
Discovered as part of #10178.

@bdice bdice added bug Something isn't working Needs Triage Need team to review and classify labels Aug 31, 2022
@bdice bdice assigned bdice and unassigned bdice Aug 31, 2022
@bdice bdice added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Aug 31, 2022
@github-actions
Copy link

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.

@galipremsagar galipremsagar self-assigned this Nov 14, 2022
rapids-bot bot pushed a commit that referenced this issue Nov 16, 2022
Fixes: #11636 
This PR:

- [x] Fixes an `UnboundLocalError` error.
- [x] Fixes reflected binary operations and added tests for the same.

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #12142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants