-
Notifications
You must be signed in to change notification settings - Fork 912
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
Enable rounding for Decimal32 and Decimal64 in cuDF #17332
Enable rounding for Decimal32 and Decimal64 in cuDF #17332
Conversation
Thanks @a-hirota! Could you please add a test that would have failed with the old code that succeeds now? You should be able to construct the expected decimal column and then compare it to what you get out of rounding. |
- Added test cases for "half_up" and "half_even" rounding modes. - Tested both Decimal32Dtype and Decimal64Dtype with various precisions and scales. - Ensured coverage for edge cases like .5 rounding to the nearest even number in "half_even". - Verified correctness of rounding logic across different decimal places.
Thank you @vyasr for your feedback! I’ve added test cases that validate the rounding behavior for both Decimal32Dtype and Decimal64Dtype with the half_up and half_even rounding modes. These include scenarios where the previous code would have produced incorrect results, such as rounding .5 values inconsistently in the half_even mode. The expected output is constructed explicitly for each test case, and assertions ensure the correctness of the implementation. Let me know if there's anything else you'd like me to adjust or add! |
Co-authored-by: Matthew Roeschke <[email protected]>
Co-authored-by: Matthew Roeschke <[email protected]>
Removed comments and print statements from the test function as requested. Clarified the approach for handling "half_up" and "half_even" rounding methods.
/ok to test |
@a-hirota looks like you need to fix the style, could you please run pre-commit? |
Ran pre-commit to address style issues as per review feedback. This ensures consistency with project coding standards.
@vyasr |
No worries! Thank you. |
/ok to test |
/ok to test |
@a-hirota it looks like pre-commit is still making changes to the test that you added. |
/ok to test |
/ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks @a-hirota
/merge |
4764395
into
rapidsai:branch-25.02
Description
Checklist
Example of Behavior After Modification
The following example demonstrates the behavior of the round function for both float and Decimal32Dtype before and after the modification.
Output
After Modification
For Decimal32Dtype, rounding works as expected:
Before Modification
For Decimal32Dtype, rounding did not modify the values:
This example shows that, prior to this modification, rounding had no effect on Decimal32Dtype columns, while after the change, Decimal32Dtype columns round as expected.
Additional Information
cuDF currently does not support rounding for Decimal types, limiting its functionality compared to libcudf, which does support it.
Updated the cols definition in cudf/python/cudf/cudf/core/indexed_frame.py to allow rounding for Decimal32 and Decimal64 types. The modified code now checks if col.dtype is of Decimal32 or Decimal64 type, allowing rounding directly on these columns without making a copy.
Using apply in Pandas can achieve similar functionality, but it is not as efficient as a native rounding method in cuDF.
This enhancement improves consistency between cudf and libcudf by enabling direct rounding of Decimal types in cudf.