Fix BoundsError on empty pulses in paired_representation - #8
Open
LucaMariaMoccia wants to merge 2 commits into
Open
Fix BoundsError on empty pulses in paired_representation#8LucaMariaMoccia wants to merge 2 commits into
LucaMariaMoccia wants to merge 2 commits into
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
==========================================
- Coverage 34.09% 33.97% -0.13%
==========================================
Files 6 8 +2
Lines 1044 1042 -2
==========================================
- Hits 356 354 -2
Misses 688 688 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mediavince
reviewed
Mar 17, 2026
mediavince
reviewed
Apr 8, 2026
| end | ||
| if !isempty(pre_pulses) | ||
| pre_pulses_aux = pre_pulses .- start_time | ||
| for i in 2:repeat_times |
Contributor
There was a problem hiding this comment.
possible optimization by having one loop and check inside it as opposed to doing twice the loop, but maybe not that essential
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.
This PR fixes a
BoundsErrorthat was identified during an automated scan of the protocol database.The issue:
When processing certain protocols that do not contain any pre-synaptic or post-synaptic pulses (such as the
oconnorandCao-TBSprotocols), the paired_representation function crashes. The error occurs because the loop tries to access the last element of an empty array (pre_pulses[end]orpost_pulses[end]) to calculate the timing of repeated epochs.The fix:
Added if
!isempty(pre_pulses)and if!isempty(post_pulses)conditional checks around the repetition loops insrc/UtilsData.jl. This safely protects the array access and prevents the crash for protocols with empty pulse lists, while keeping the logic intact for standard protocols.