fix: keep overlap labels aligned with boxes - #4445
Open
uczltw6 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Shadow auto-approve: would auto-approve. Fix catch_overlapping_and_nested_bboxes() so labels/text are only appended for coordinate-bearing elements, preventing index misalignment in overlap reports. Adds a regression test and bumps version/changelog.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
catch_overlapping_and_nested_bboxes()already excludes elements without coordinates from its bounding-box collection, but it still appended their labels and text to the parallel collections. A coordinate-less element therefore shifted those collections, causing later overlap and parent-child reports to name the wrong elements and content.The fix appends all three values only for coordinate-bearing elements, so every index used by the overlap detector refers to the same source element.
Tests
python3 -m pytest test_unstructured/test_utils.py -q— 38 passedpython3 -m ruff check unstructured/utils.py test_unstructured/test_utils.pypython3 -m ruff format --check unstructured/utils.py test_unstructured/test_utils.pygit diff --checkAI assistance was used to help identify the edge case and prepare the focused patch. The behavior and test results were verified locally.