Skip to content

Add crop bounds validation for split XML IPD implementation#169

Merged
seanmcculloch merged 3 commits intofeat/squashed-split-xml-ipdfrom
copilot/sub-pr-167
Feb 15, 2026
Merged

Add crop bounds validation for split XML IPD implementation#169
seanmcculloch merged 3 commits intofeat/squashed-split-xml-ipdfrom
copilot/sub-pr-167

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 15, 2026

Description of the Changes You Made

Adds validation to catch invalid crop bounds before Dask raises IndexError. When crop bounds exceed array dimensions after transpose, the error message was cryptic. Now validates early with clear diagnostics.

Validation checks:

  • crop_min[i] >= 0 (non-negative bounds)
  • crop_max[i] < array_shape[i] (within dimensions)
  • crop_min[i] <= crop_max[i] (valid range)

Error messages now include:

  • Which dimension failed
  • The invalid value
  • The actual array shape
# Before: IndexError from Dask with no context
# After: ValueError with clear message
raise ValueError(
    f"crop_max[0]=15 exceeds array dimension 0 "
    f"(shape=10); crop_max must be < array shape"
)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Instructions for Testing

Run python tests/test_detection/test_image_reader.py - includes 3 new test cases covering each validation scenario.

Additional Info

Addresses feedback from PR #167: #167 (comment)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 15, 2026 03:10
Co-authored-by: seanmcculloch <86432671+seanmcculloch@users.noreply.github.com>
Co-authored-by: seanmcculloch <86432671+seanmcculloch@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on XML IPD split implementation Add crop bounds validation for split XML IPD implementation Feb 15, 2026
Copilot AI requested a review from seanmcculloch February 15, 2026 03:12
@seanmcculloch seanmcculloch marked this pull request as ready for review February 15, 2026 04:11
@seanmcculloch seanmcculloch merged commit a82474c into feat/squashed-split-xml-ipd Feb 15, 2026
@seanmcculloch seanmcculloch deleted the copilot/sub-pr-167 branch February 15, 2026 04:12
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