← 输入框|github.com|刷新
Skip to content

fix(utils): recognize a box nested when the tolerance is zero - #4507

Merged
cragwolfe merged 4 commits into
Unstructured-IO:mainfrom
SashaMIT:fix/exact-nesting
Oct 24, 2026
Merged

cragwolfe merged 4 commits into
Unstructured-IO:mainfrom
SashaMIT:fix/exact-nesting

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

is_parent_box() only copied the parent box when the pixel tolerance was truthy. With the default tolerance of 0 it compared the child with the origin, so a box that sits inside its parent came back as not nested.

is_parent_box((0, 0, 100, 100), (10, 10, 20, 20))
# False
is_parent_box((0, 0, 100, 100), (15, 15))
# False

catch_overlapping_and_nested_bboxes(..., nested_error_tolerance_px=0) uses that path, so an exactly nested pair was classified as a partial overlap.

Fix

The parent coordinates are always the comparison box. A positive tolerance still grows that box by the same number of pixels. A child outside the parent is still rejected, including one that only fits because of slack.

Tests

test_a_box_nested_with_no_tolerance_is_inside_its_parent fails on the origin comparison (False) and passes once the parent box is used (True). A point inside the parent is included. A box outside stays out, and one pixel of slack still accepts a box that starts one pixel outside.

Review in cubic

SashaMIT and others added 2 commits September 30, 2026 00:10
is_parent_box compared the child with the origin whenever the pixel tolerance was 0, so a box inside its parent was reported as not nested.

@cragwolfe cragwolfe 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.

Reviewed commit 5ebef0e with GPT Pro. No actionable introduced defects found. Zero tolerance now compares against the parent coordinates, positive-tolerance behavior is preserved, and the new regression test detects the original failure. The downstream nesting checks handle containment in either input order.

The source review is clean. Five of six required checks currently pass; test_dockerfile is still running, so integration readiness remains pending. Tests were reviewed as source; no local tests were run.

(authored by codex)

@cragwolfe cragwolfe 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.

Reviewed commit 5ebef0e with GPT Pro. No actionable correctness or regression issues found. Zero tolerance now uses the parent bounds, and nonzero tolerance retains its prior behavior. The regression test covers contained boxes and points, outside boxes, and positive tolerance.

Exact-head unit, dependency, lint, Docker, and security checks passed at review time; the runtime comparison was still running. No local tests were run.

(authored by codex)

@cragwolfe
cragwolfe merged commit ef95052 into Unstructured-IO:main Oct 24, 2026
51 checks passed
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Thanks for merging this. A zero tolerance now compares against the parent box.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants