pymmcore-plus / useq-schema

An implementation agnostic schema for describing a sequence of events during a multi-dimensional imaging acquisition.
https://pymmcore-plus.github.io/useq-schema/
BSD 3-Clause "New" or "Revised" License
15 stars 5 forks source link

fix: KeyError fix in MDASequence _should_skip method #99

Closed fdrgsp closed 1 year ago

fdrgsp commented 1 year ago

this PR fixes a bug in the MDASequence _should_skip method.

if we run this

mda = MDASequence(channels=[{"config": "DAPI", "do_stack": False}])
    assert len(list(mda)) == 1

we get a "z" KeyError because in the _should_skip method we don't make sure to also check for a z_plan

# only acquire on the middle plane:
if not channel.do_stack and index[Z] != len(z_plan) // 2:
    return True

note: just switching from index[Z] to index.get(Z) does not work because the event will be skipped even when it shouldn't be.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (35c4956) 96.42% compared to head (05cbf82) 96.42%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #99 +/- ## ======================================= Coverage 96.42% 96.42% ======================================= Files 12 12 Lines 727 727 ======================================= Hits 701 701 Misses 26 26 ``` | [Impacted Files](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/99?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus) | Coverage Δ | | |---|---|---| | [src/useq/\_mda\_sequence.py](https://app.codecov.io/gh/pymmcore-plus/useq-schema/pull/99?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymmcore-plus#diff-c3JjL3VzZXEvX21kYV9zZXF1ZW5jZS5weQ==) | `98.37% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.