ENH: allow recursive callOnFlip() calls#6814
Merged
peircej merged 1 commit intopsychopy:devfrom Sep 16, 2024
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #6814 +/- ##
==========================================
- Coverage 49.61% 49.61% -0.01%
==========================================
Files 332 332
Lines 61227 61228 +1
==========================================
Hits 30378 30378
- Misses 30849 30850 +1
|
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.
TL;DR:
I've abstracted some functionality in psychopy to make running a suite of experiments easier to work with for our team. Unfortunately, during implementation of a
VisualStimphotodiode trigger that can synchronize with aParallelPorttrigger, I came across a bug that prevented schedulingcallOnFlipwithin a function scheduled the previous frame.This PR fixes that by first checking the length of
self._toCall, then running those scheduled functions, and finally, deleting those elements up to the prior length.This allows things like:
nframesnframesnseconds using thisMonotonicClocknframes or seconds regardless of what is happening in the experiment (as long as frames are flipping)This avoids requiring an explicit call to
win.callOnFlip()in each context / trial / etc loop where awin.flip()call may occur (there are still all the same performance considerations, anything with recursivewin.callOnFlip()should follow all the same guidelines as if you were running a loop with the scheduled function executing once per frame)I'm using the change in my code and now the display no longer halts, but instead displays the stimuli correctly, and updates other elements as expected.
Example code making use of this: