Skip to content

Fix duplicate bin detection for large cut inputs - #23601

Open
fallintoplace wants to merge 3 commits into
NVIDIA:mainfrom
fallintoplace:fix-cut-duplicate-bin-detection
Open

Fix duplicate bin detection for large cut inputs#23601
fallintoplace wants to merge 3 commits into
NVIDIA:mainfrom
fallintoplace:fix-cut-duplicate-bin-detection

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix duplicate edge detection in cudf.cut.
  • Add a regression test with 257 unique bin edges.

The old check used object identity when comparing the lengths of the input and its set of unique values. For larger edge lists, equal integer lengths can be different objects, so a sequence with unique edges could be reported as containing duplicates. The new check compares the values directly.

Testing

  • python3 -m py_compile python/cudf/cudf/core/cut.py python/cudf/cudf/tests/general_functions/test_cut.py
  • git diff --check

@fallintoplace
fallintoplace requested a review from a team as a code owner August 8, 2026 19:08
@copy-pr-bot

copy-pr-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Python Affects Python cuDF API. label Aug 8, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ca785a9a-428f-4987-b208-59088f7c29a5

📥 Commits

Reviewing files that changed from the base of the PR and between 79764d7 and e471df2.

📒 Files selected for processing (1)
  • python/cudf/cudf/tests/general_functions/test_cut.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • python/cudf/cudf/tests/general_functions/test_cut.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved duplicate bin-edge detection in cut, ensuring equal values are identified correctly even when represented by distinct objects.
    • Fixed binning with 256 unique bin edges when labels are disabled.
  • Tests

    • Added regression coverage for 256 unique bin edges.
    • Added validation that duplicate large integer edges raise an error.

Walkthrough

The cut duplicate-bin-edge validation now uses value equality. Regression tests cover 256 unique bins and duplicate large integer edges represented by distinct objects.

Changes

Cut bin-edge validation

Layer / File(s) Summary
Bin-edge validation and regression coverage
python/cudf/cudf/core/cut.py, python/cudf/cudf/tests/general_functions/test_cut.py
The duplicate-bin-edge check now compares values instead of object identity. Tests compare 256 unique bins with pandas and verify that duplicate large integer edges raise ValueError.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: matt711

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the fix to duplicate bin detection in large cut inputs.
Description check ✅ Passed The description explains the duplicate-edge detection fix and the regression test added for large bin-edge inputs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/cudf/cudf/tests/general_functions/test_cut.py`:
- Around line 233-240: Extend test_cut_unique_bins_larger_than_integer_cache
with a duplicate-edge case using independently constructed equal integer objects
above 256, ensuring identity-based detection is exercised. Verify cut matches
pandas for the default duplicates="raise" behavior or explicitly test
duplicates="drop" with the corresponding expected result.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 112a3117-4d91-4f3e-a27a-2e7f58b818d6

📥 Commits

Reviewing files that changed from the base of the PR and between 6a22d1d and 06210a1.

📒 Files selected for processing (2)
  • python/cudf/cudf/core/cut.py
  • python/cudf/cudf/tests/general_functions/test_cut.py

Comment thread python/cudf/cudf/tests/general_functions/test_cut.py
Comment thread python/cudf/cudf/tests/general_functions/test_cut.py

@mroeschke mroeschke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. One question before I initiate the test suite

@mroeschke mroeschke added bug Something isn't working non-breaking Non-breaking change labels Aug 10, 2026
@mroeschke

Copy link
Copy Markdown
Contributor

/ok to test e471df2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants