Skip to content

test(canvas): cover _is_out_of_image boundary semantics - #2369

Merged
wkentaro merged 1 commit into
mainfrom
test/canvas-is-out-of-image
Aug 4, 2026
Merged

test(canvas): cover _is_out_of_image boundary semantics#2369
wkentaro merged 1 commit into
mainfrom
test/canvas-is-out-of-image

Conversation

@wkentaro

Copy link
Copy Markdown
Owner

_is_out_of_image was the sole module-level helper in canvas.py with no direct
unit coverage — every sibling (_normalize_bbox_points, _snap_cursor_pos_for_square,
etc.) is already imported and tested in canvas_test.py. It backs is_out_of_pixmap,
which gates vertex/shape clamping throughout the drag/move/reproject paths, so its
inclusive-at-both-edges boundary convention is load-bearing.

This pins that convention: the top-left (0, 0) and far (width, height) corners
count as inside, an interior point is inside, and a point just past any of the four
edges is out.

Test plan

  • uv run pytest tests/unit/widgets/canvas_test.py (114 passed)
  • make lint (ruff check, ruff format --check, ty check all clean)

@wkentaro wkentaro self-assigned this Jul 19, 2026
@wkentaro

Copy link
Copy Markdown
Owner Author

This was generated by AI during PR processing.

Verdict: recommend-merge

Test-only change adding test_is_out_of_image, which parametrizes the boundary semantics of labelme._widgets.canvas._is_out_of_image (7 cases: interior/corners inside, and each of the four out-of-bounds directions).

  • Verified the assertions against the source: the function uses < 0 / > size, so the far width/height edge is inclusive-inside, exactly as the test asserts and its comment documents.
  • No rebase needed: branch is up to date with main (0 commits gained since merge-base, no file overlap), so the existing CI green reflects the merged result.
  • /code-review (medium): no findings. Import placement is alphabetical, annotations present, matches repo test conventions.
  • CI green across all platforms (ubuntu/macos/windows × 3.12-3.14), lint and cla passing.

No CHANGELOG entry (not user-facing). Ready for maintainer to merge.

@wkentaro wkentaro added the recommend-merge pr: Agent finalized and endorses it: review and merge label Jul 19, 2026
@wkentaro
wkentaro force-pushed the test/canvas-is-out-of-image branch from d5220fb to 126e1f7 Compare August 4, 2026 04:56
@wkentaro wkentaro added this to the next milestone Aug 4, 2026
_is_out_of_image was the sole module-level helper in canvas.py with no
direct unit coverage. Pin its inclusive-at-both-edges convention: the top-left
and far width/height corners count as inside, while a point just past any edge
is out. This is the semantics is_out_of_pixmap relies on to gate vertex/shape
clamping.
@wkentaro
wkentaro force-pushed the test/canvas-is-out-of-image branch from 126e1f7 to 10d2880 Compare August 4, 2026 11:29
@wkentaro
wkentaro merged commit e5c0d7b into main Aug 4, 2026
12 checks passed
@wkentaro
wkentaro deleted the test/canvas-is-out-of-image branch August 4, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recommend-merge pr: Agent finalized and endorses it: review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant