iterator gap fix#11
Open
kylmcgr wants to merge 3 commits into
Open
Conversation
kylmcgr
commented
Jun 9, 2026
- NWBAxisArrayIterator now splits chunks that contain a gap.
- NWBClockDrivenProducer now returns a CoordinateAxis with the true per-sample timestamps instead of a LinearAxis.
…e timestamps instead of LinearAxis
There was a problem hiding this comment.
Pull request overview
This PR improves correctness when NWB streams have explicit timestamps that include gaps by preventing time axes from implicitly “flattening” over missing time. It updates both chunked iteration and clock-driven playback to preserve true per-sample time semantics across gaps.
Changes:
- Add gap detection (
find_gaps) and use it to split iterator chunks that span timestamp gaps. - Update
NWBSlicer.read_by_time(andNWBClockDrivenProducer) to emit aCoordinateAxiswith true per-sample timestamps when a requested window spans a gap. - Add comprehensive tests + new gappy/irregular NWB fixtures to validate behavior, including the
gap_tolcontrol.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/ezmsg/nwb/slicer.py |
Adds gap detection helper and switches read_by_time to CoordinateAxis when windows span gaps. |
src/ezmsg/nwb/iterator.py |
Splits chunk messages at detected timestamp gaps; plumbs gap_tol through iterator settings and prefetch worker. |
src/ezmsg/nwb/clockdriven.py |
Forwards gap_tol into slicer time-window reads so clock-driven playback preserves true timestamps across gaps. |
tests/conftest.py |
Adds session-scoped fixtures that generate synthetic gappy and irregular timestamped NWB files for testing. |
tests/test_slicer.py |
Adds slicer-level tests covering gap-free windows, gap-spanning windows, inside-gap empty windows, and irregular streams. |
tests/test_iterator.py |
Adds iterator-level tests ensuring chunks are split at gaps without dropping/reordering samples; tests gap_tol behavior. |
tests/test_clockdriven.py |
Adds clock-driven tests verifying empty chunks inside gaps, CoordinateAxis for gap-spanning windows, and multi-producer sync across gaps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
485
to
+489
| out_data = info.dset[start_idx:stop_idx] | ||
| time_axis = template.axes["time"] | ||
| ts_window = np.asarray(ts_arr[start_idx:stop_idx]) | ||
| has_gain = hasattr(time_axis, "gain") | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.