Skip to content

Fix descending uniform-coordinate binned selection in ImageTool#376

Merged
kmnhan merged 4 commits into
mainfrom
fix-imagetool-decreasing-coordinates
May 30, 2026
Merged

Fix descending uniform-coordinate binned selection in ImageTool#376
kmnhan merged 4 commits into
mainfrom
fix-imagetool-decreasing-coordinates

Conversation

@kmnhan
Copy link
Copy Markdown
Owner

@kmnhan kmnhan commented May 30, 2026

Summary

  • Clamp ImageTool bin slices at array boundaries so edge cursors no longer produce empty selections.
  • Make qsel_args_from_indexers safe for descending uniform coordinates by rejecting empty bins early, emitting non-negative widths, and validating against reversed slice bounds when needed.
  • Reuse the boundary-safe slice logic in both hidden-axis binning paths so xslice and averaged selection stay consistent.
  • Add regressions for descending-coordinate binning, qsel reconstruction, and xslice near a boundary.

Testing

  • Not run (not requested)
  • Added unit regressions covering _bin_slice, qsel_args_from_indexers, and xslice on descending uniform coordinates.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an ImageTool bug where binning at the boundary of a descending uniform coordinate produced empty selections, and makes qsel_args_from_indexers correctly handle descending coordinates by always emitting non-negative bin widths and validating against a reversed slice.

Changes:

  • Clamp/redistribute _bin_slice bounds at array boundaries so edge cursors don't yield empty windows.
  • Make qsel_args_from_indexers produce non-negative widths and validate using a reversed slice for descending coords.
  • Reuse _bin_slice in both hidden-axis binning paths (_bin_along_axis / _bin_along_multiaxis) to keep slicing consistent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/erlab/interactive/imagetool/slicer.py Boundary clamping in _bin_slice, descending-coord safety in qsel_args_from_indexers, and reuse of _bin_slice in binning helpers.
tests/interactive/imagetool/test_slicer.py Adds regressions for boundary _bin_slice, descending-coord qsel_args_from_indexers, and xslice with descending hidden axis.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kmnhan kmnhan enabled auto-merge (squash) May 30, 2026 00:49
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.89%. Comparing base (f966c25) to head (d3a6910).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/erlab/interactive/imagetool/slicer.py 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #376   +/-   ##
=======================================
  Coverage   88.89%   88.89%           
=======================================
  Files         139      139           
  Lines       47155    47165   +10     
  Branches     7588     7592    +4     
=======================================
+ Hits        41918    41927    +9     
  Misses       3271     3271           
- Partials     1966     1967    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kmnhan kmnhan merged commit dc94962 into main May 30, 2026
23 of 24 checks passed
@kmnhan kmnhan deleted the fix-imagetool-decreasing-coordinates branch May 30, 2026 01:00
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