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

[REVIEW] Clip decimal binary op precision at max precision #8194

Merged
merged 6 commits into from
May 27, 2021
Merged
Changes from 5 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
6 changes: 4 additions & 2 deletions python/cudf/cudf/core/column/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ def _binop_precision(l_dtype, r_dtype, op):
p1, p2 = l_dtype.precision, r_dtype.precision
s1, s2 = l_dtype.scale, r_dtype.scale
if op in ("add", "sub"):
return max(s1, s2) + max(p1 - s1, p2 - s2) + 1
result = max(s1, s2) + max(p1 - s1, p2 - s2) + 1
elif op in ("mul", "div"):
return p1 + p2 + 1
result = p1 + p2 + 1
else:
raise NotImplementedError()

return min(result, cudf.Decimal64Dtype.MAX_PRECISION)