Skip to content

Reject bandpass centers at or above Nyquist, fix auto grid endpoint - #42

Open
SID-6921 wants to merge 1 commit into
pactools:masterfrom
SID-6921:fix/reject-above-nyquist-centers
Open

SID-6921 wants to merge 1 commit into
pactools:masterfrom
SID-6921:fix/reject-above-nyquist-centers

Conversation

@SID-6921

Copy link
Copy Markdown

Closes #41

multiple_band_pass only checked frequency <= 0, with no upper bound. A center at or above the Nyquist frequency (fs / 2) passed straight through to the sampled cosine/sine kernel, which aliases it onto a lower frequency instead of raising:

Comodulogram(fs=1000.0, high_fq_range=[450.0, 500.0, 550.0], ...)  # 500, 550 silently alias

high_fq_range="auto" built its grid with np.linspace(..., fs / 2.0, 80), which includes fs / 2 as its last point by default, so the auto grid hit this exact case on every call.

Fix:

  • multiple_band_pass now raises ValueError for any center >= fs / 2, matching the existing style of the frequency <= 0 check right above it.
  • The "auto" grid drops any point that landed at or past fs / 2 instead of including it.

Verified against the reproduction from #41: centers at 500 and 550 Hz (fs=1000) now raise, the auto grid's last point is below Nyquist and the comodulogram still fits cleanly, and a normal below-Nyquist center is unaffected. Added a regression test (test_high_fq_range_rejects_nyquist_and_above) that fails on the pre-fix code and passes after. Ran the full test_comodulogram.py: same pre-existing failures as on an unmodified checkout (dependency-version issues unrelated to this change), nothing new broken. flake8 clean on the three changed files.

I scoped this to the validation + auto-grid fix from the issue's first proposed point. Left the exact-Nyquist special-case documentation and the general bandwidth-margin-near-DC/Nyquist discussion (the issue's second and third points) out of this PR, since they're design questions rather than a single scoped fix.

multiple_band_pass only rejected frequency <= 0, so a center at or
above fs/2 passed through to the sampled cosine/sine kernel, which
aliases it onto a lower frequency instead of raising. high_fq_range
="auto" built its grid with np.linspace up to fs/2 inclusive, so it
hit this exact case on its last point every time. Added the upper
bound check and dropped the Nyquist point from the auto grid.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 04:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@SID-6921

Copy link
Copy Markdown
Author

Hi, just checking in on this one. It's a small, self-contained fix (rejecting bandpass centers at or above Nyquist, fixing the auto grid endpoint), still mergeable with no conflicts. Let me know if anything needs changing.

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.

Comodulogram accepts above-Nyquist centers; auto grid includes Nyquist

2 participants