Skip to content

Comments

[WIP] fix: handle absolute grid positions in _build_stage_positions_plan#104

Open
fdrgsp wants to merge 3 commits intopymmcore-plus:mainfrom
fdrgsp:fix-absolute-grid
Open

[WIP] fix: handle absolute grid positions in _build_stage_positions_plan#104
fdrgsp wants to merge 3 commits intopymmcore-plus:mainfrom
fdrgsp:fix-absolute-grid

Conversation

@fdrgsp
Copy link
Contributor

@fdrgsp fdrgsp commented Feb 19, 2026

When a grid plan yields AbsolutePosition objects (e.g. GridFromEdges, GridFromPolygon, RandomPoints), adding them to another Position in _build_stage_positions_plan is invalid. Previously the code always attempted pos + gp, which would fail for absolute positions.

Two fixes are applied:

Check gp.is_relative and use gp directly when the grid position is absolute.
When an absolute grid position has no row/col (e.g. GridFromPolygon, RandomPoints), append a positional index to the parent name to ensure uniqueness (e.g. my_pos_0000).

@fdrgsp fdrgsp added the bug Something isn't working label Feb 19, 2026
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.33%. Comparing base (83ee949) to head (a98ffbd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #104   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files          20       20           
  Lines        2044     2047    +3     
=======================================
+ Hits         2010     2013    +3     
  Misses         34       34           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fdrgsp fdrgsp changed the title fix: handle absolute grid positions in _dims_from_useq [WIP] fix: handle absolute grid positions in _dims_from_useq Feb 19, 2026
@fdrgsp fdrgsp changed the title [WIP] fix: handle absolute grid positions in _dims_from_useq [WIP] fix: handle absolute grid positions in _build_stage_positions_plan Feb 19, 2026
Comment on lines +211 to +219
stage_positions=[(0.0, 0.0)],
grid_plan=useq.GridFromEdges(
fov_width=50.0,
fov_height=50.0,
left=0.0,
right=100.0,
top=0.0,
bottom=100.0,
),
Copy link
Member

Choose a reason for hiding this comment

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

this is indeed an interesting case. I think an argument could be made that this sequence itself should be an error? I mean... what does it even mean to acquire a grid bounded by (left,right,top,bottom) that is centered around stage_position (0,0)? It just "happens" to be the case here that (0,0) is inside the grid, but what if it weren't?

doesn't this kinda feel like a useq-schema bug? and not an ome-writers one?

Comment on lines +237 to +250
useq.Position(
x=10.0,
y=10.0,
name="grid",
sequence=useq.MDASequence(
grid_plan=useq.GridFromEdges(
fov_width=50.0,
fov_height=50.0,
left=0.0,
right=100.0,
top=0.0,
bottom=50.0,
)
),
Copy link
Member

Choose a reason for hiding this comment

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

same here... it becomes even more obvious that it's internally contradictory of you were to have set position to (-10, -10) rather than 10, 10 ... what does it even mean to set the position with an absolute grid?

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants