Skip to content
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

Fix fractional centers in CircularConvolve #471

Merged
merged 4 commits into from
Nov 15, 2023
Merged

Fix fractional centers in CircularConvolve #471

merged 4 commits into from
Nov 15, 2023

Conversation

Michael-T-McCann
Copy link
Contributor

Using a fractional filter center for a CircularConvolve operator currently gives nonsense results. This PR adds a test for this nonsense (checking that the imaginary part of the result of filtering is small) and changes the way centers are handled to fix the problem. Relevant references:

F. Candocia and J. C. Principe, "Comments on "Sinc interpolation of discrete periodic signals," in IEEE Transactions on Signal Processing, vol. 46, no. 7, pp. 2044-2047, July 1998, doi: 10.1109/78.700979.

"S. -C. Pei and Y. -C. Lai, "Closed Form Variable Fractional Time Delay Using FFT," in IEEE Signal Processing Letters, vol. 19, no. 5, pp. 299-302, May 2012, doi: 10.1109/LSP.2012.2191280.

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4efcba4) 94.57% compared to head (6438014) 94.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #471      +/-   ##
==========================================
- Coverage   94.57%   94.56%   -0.02%     
==========================================
  Files          90       90              
  Lines        5585     5584       -1     
==========================================
- Hits         5282     5280       -2     
- Misses        303      304       +1     
Flag Coverage Δ
unittests 94.56% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

def test_fractional_center(self):
"""A fractional center should keep outputs real"""
x, _ = uniform(minval=-1, maxval=1, shape=(4, 5), key=self.key)
h, _ = uniform(minval=-1, maxval=1, shape=(2, 2), key=self.key)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be a bit better to not discard the key returned by the first call to unform, instead using it as the second key.

@bwohlberg bwohlberg self-requested a review November 15, 2023 23:52
@bwohlberg bwohlberg merged commit 61f1c93 into main Nov 15, 2023
17 checks passed
@bwohlberg bwohlberg deleted the mike/shift branch November 15, 2023 23:52
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.

2 participants