-
-
Notifications
You must be signed in to change notification settings - Fork 42
🐛 Fix ideal_bandpass filter #2237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
06ed6cf
to
4b0bf06
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2237 +/- ##
=========================================
+ Coverage 28.1% 28.3% +0.2%
=========================================
Files 230 230
Lines 25941 25978 +37
Branches 4081 4081
=========================================
+ Hits 7299 7353 +54
+ Misses 18013 17996 -17
Partials 629 629
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. And it resolved the crash I was hitting in #2230!
We could add a parameterization where LowCutoff > nyquist_freq
and HighCutoff > nyquist_freq or HighCutoff is None
(1) and this other parameterization and get full coverage of this PR, but I also think it's good to go as-is.
Footnotes
-
Is it conceptually correct that those are both
> nyquist_freq
? I see it was already that way, and I don't know enough about filtering terminology to know if that's intended ↩
Co-authored-by: Jon Cluce <[email protected]>
for more information, see https://pre-commit.ci
@shnizzedy , Yes |
Fixes
Fixes
numpy.linalg.LinAlgError: singular matrix
error in #2225 by @shnizzedyFixes eigenvector centrality crash in in-progress #2230 by @shnizzedy
Description
This PR fixes a bug in the ideal_bandpass function where the frequency mask was incorrectly applied, which could cause the filter to fail or behave unexpectedly, especially for certain edge cases in bandpass frequency selection.
The issue was caused by an incorrect use of boolean logic (f_data[freq_mask is not True] = 0.0) which did not apply the mask elementwise. This has now been corrected to f_data[~freq_mask] = 0.0.
Technical details
Replaced
with
which applies the negation elementwise, as intended.
The FFT zero-padding and bandpass index calculation remain unchanged in terms of functionality. Variable naming was slightly improved for readability (e.g., nyquist_freq used instead of repeated sample_freq / 2.0).
Tests
Manually inspected non-zero outputs from this function.
Screenshots
Before fix

After fix

Checklist
Update index.md
).develop
branch of the repository.Developer Certificate of Origin
Developer Certificate of Origin