Fix rolling_filter window=1 edge case by returning early and add test#888
Open
VPK570 wants to merge 8 commits intoneuroinformatics-unit:mainfrom
Open
Fix rolling_filter window=1 edge case by returning early and add test#888VPK570 wants to merge 8 commits intoneuroinformatics-unit:mainfrom
VPK570 wants to merge 8 commits intoneuroinformatics-unit:mainfrom
Conversation
for more information, see https://pre-commit.ci
Fix SonarCloud warnings in rolling_filter window=1 test
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
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.



Description
What is this PR
Why is this PR needed?
Calling
rolling_filterwithwindow=1currently returns an emptyDataArray.A window size of 1 is a valid no-op filter and should return the original data unchanged.
The issue occurs because when
window=1,half_window = window // 2 = 0.The trim step then calls
isel(time=slice(0, -0)), which evaluates toslice(0, 0)and results in an empty array.What does this PR do?
rolling_filterwhenwindow == 1window=1References
Closes #887
How has this PR been tested?
test_rolling_filter_window_1that checks the output equals the input whenwindow=1.pytestto ensure existing tests pass and no regressions were introduced.Is this a breaking change?
No. This change only fixes an edge case and does not modify existing behavior for other window sizes.
Does this PR require an update to the documentation?
No. This change fixes an internal bug and does not introduce any new functionality.