Skip to content

[ENH] - Add signal yielder functionality - #356

Merged
TomDonoghue merged 3 commits into
mainfrom
yielders
Oct 29, 2025
Merged

[ENH] - Add signal yielder functionality#356
TomDonoghue merged 3 commits into
mainfrom
yielders

Conversation

@TomDonoghue

@TomDonoghue TomDonoghue commented Oct 19, 2025

Copy link
Copy Markdown
Member

This PR add some helper / utility functions for iterating across arrays. With long time series, in some cases it can be useful to iterate across segments. It adds a function to step across time (for a 1D or 2D array) and a separate function for stepping across 'channels' (across rows within a 2D array).

@neurodsp-tools neurodsp-tools deleted a comment from codecov Bot Oct 19, 2025
@neurodsp-tools neurodsp-tools deleted a comment from codecov Bot Oct 27, 2025
@TomDonoghue TomDonoghue changed the title [WIP] - Add signal yielder functionality [ENH] - Add signal yielder functionality Oct 28, 2025

@ryanhammonds ryanhammonds left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! The I see the usefulness of step_over_time. I'm unsure the use case for:

for sig in step_over_signals(signals):
    pass

This seems more verbose than calling:

for sig in signals:
    pass

Maybe the generator is useful for other cases:

gen = (sig for sig in signals)
next(gen)

gen = step_over_signals(signals)
next(gen)

Anyways this looks good to me!

@neurodsp-tools neurodsp-tools deleted a comment from codecov Bot Oct 29, 2025
@TomDonoghue

Copy link
Copy Markdown
Member Author

Thanks for checking @ryanhammonds!

I agree the time stepper is more useful, I added the channel stepper somewhat for completeness. The use case I was thinking of like the last version you noted - creating a generator at some point, and calling next as needed (I've been doing things like this in the use case that I've been using these in, which is making some gifs).

@TomDonoghue
TomDonoghue merged commit f164bb4 into main Oct 29, 2025
9 of 10 checks passed
@TomDonoghue
TomDonoghue deleted the yielders branch October 29, 2025 11:13
@neurodsp-tools neurodsp-tools deleted a comment from codecov Bot Oct 29, 2025
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