Skip to content

Fix BoundsError on empty pulses in paired_representation - #8

Open
LucaMariaMoccia wants to merge 2 commits into
rveltz:mainfrom
LucaMariaMoccia:fix-boundserror-empty-pulses
Open

Fix BoundsError on empty pulses in paired_representation#8
LucaMariaMoccia wants to merge 2 commits into
rveltz:mainfrom
LucaMariaMoccia:fix-boundserror-empty-pulses

Conversation

@LucaMariaMoccia

Copy link
Copy Markdown

This PR fixes a BoundsError that 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 oconnor and Cao-TBS protocols), the paired_representation function crashes. The error occurs because the loop tries to access the last element of an empty array (pre_pulses[end] or post_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 in src/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.

@codecov-commenter

codecov-commenter commented Mar 13, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.97%. Comparing base (84b8e19) to head (b471291).
⚠️ Report is 49 commits behind head on main.

Files with missing lines Patch % Lines
src/UtilsData.jl 0.00% 10 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/UtilsData.jl Outdated
Comment thread src/UtilsData.jl
end
if !isempty(pre_pulses)
pre_pulses_aux = pre_pulses .- start_time
for i in 2:repeat_times

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

possible optimization by having one loop and check inside it as opposed to doing twice the loop, but maybe not that essential

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.

3 participants