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
Added normalized_epsilon as a parameter to convolve_fft #5177
Conversation
This allows the user of convolve_fft to choose the upper limit of deviation between the kernel sum and unity, so that it can for example be adjusted for the specific floating-point precision of the kernel array
@@ -312,6 +312,9 @@ def convolve_fft(array, kernel, boundary='fill', fill_value=0, crop=True, | |||
256. | |||
quiet : bool, optional | |||
Silence warning message about NaN interpolation | |||
normalized_epsilon: float, optional | |||
The upper limit on the deviation of the kernel sum with respect to unity. | |||
Will be checked only if normalize_kernel is False. |
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.
Add `` around normalize_kernel
to mark it as another keyword.
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.
Also if a parameter is optional it is custom to provide or hint at the default value. Something like Default is "1e-8".
(or defaults to xxx, ...)
Another thing that could be added is a sphinx directive when the parameter was added, something like: .. versionadded:: 1.3
(or 1.2.x).
This reminds me: This PR needs a Changelog entry (home directory /Changes.rst
) for the appropriate version/subpackage under "API changes" (or "New features").
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 more of an API change.
This looks uncontroversial enough to me, but let's see what the sub-package maintainer(s) say. Still needs a change log. |
I'm not sure if it's appropriate here but numpy has a
But that's only the minimal epsilon for the number 1, but it could provide at least an order of magnitude estimate. |
@MSeifert04 Thanks for showing that finfo() function, good to know. |
@@ -226,8 +226,8 @@ def convolve(array, kernel, boundary='fill', fill_value=0., | |||
def convolve_fft(array, kernel, boundary='fill', fill_value=0, crop=True, | |||
return_fft=False, fft_pad=None, psf_pad=None, | |||
interpolate_nan=False, quiet=False, ignore_edge_zeros=False, | |||
min_wt=0.0, normalize_kernel=False, allow_huge=False, | |||
fftn=np.fft.fftn, ifftn=np.fft.ifftn, | |||
min_wt=0.0, normalize_kernel=False, normalized_epsilon=1e-8, |
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 line contains a trailing whitespace (at the end of the line). That's why your first build failied during the PEP-8 check.
Pushing this to 2.0 as it appears @astrofrog's comments have not yet been resolved and the branch has conflits. |
I'm sorry but I currently don't have the time to look at his again.. Alas, not paid to do programming.. |
Is anyone interested to take over? If not, I guess we can close this. |
Seems pretty close to done, I could work on it Monday. May have to open a new PR with these changes cherry-picked if a force push doesn't work.... |
Closing in favor of #5649, which is this rebased, and with the comments made here addessed. |
Added normalized_epsilon as a parameter to convolve_fft (replaces #5177)
This allows the user of convolve_fft to choose the upper limit of deviation between the kernel sum and unity, so that it can for example be adjusted for the specific floating-point precision of the kernel array