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

Add support for np.correlate and np.convolve #2777

Merged
merged 2 commits into from Apr 5, 2018

Conversation

stuartarchibald
Copy link
Contributor

As title. Lack of FFT support prevents the implementation of
efficient convolution alg.

Closes #2500

@stuartarchibald stuartarchibald added this to the Numba 0.38 RC milestone Feb 28, 2018
As title. Lack of FFT support prevents the implementation of
efficient convolution alg.

Closes numba#2500
@codecov-io
Copy link

codecov-io commented Mar 1, 2018

Codecov Report

Merging #2777 into master will decrease coverage by 0.14%.
The diff coverage is 65.6%.

@@            Coverage Diff             @@
##           master    #2777      +/-   ##
==========================================
- Coverage   86.19%   86.05%   -0.15%     
==========================================
  Files         323      324       +1     
  Lines       66721    67720     +999     
  Branches     7455     7617     +162     
==========================================
+ Hits        57513    58276     +763     
- Misses       8016     8229     +213     
- Partials     1192     1215      +23

Copy link
Member

@sklam sklam left a comment

Choose a reason for hiding this comment

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

The patch looks good! I only have a small suggestion for better readability.

# For "direction", +1 to write the return values out in order 0->N
# -1 to write them out N->0.

if not (mode == 0 or mode == 2):
Copy link
Member

Choose a reason for hiding this comment

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

Can the 0 and 2 be named as sth like CORR_FULL=0 or use IntEnum for better readability?

Copy link
Member

Choose a reason for hiding this comment

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

Also, I curious to know why 1 is skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is shared by correlate and convolve, in NumPy these functions have a mode kwarg (which is not in this PR) and the default mode is different in each function. The mode ends up in C code as having value 0, 1, 2 based on the string passed to mode (one of 'valid', 'same', 'full'), this function does the conversion https://github.com/numpy/numpy/blob/v1.14.0/numpy/core/numeric.py#L862-L870. To try and reduce future confusion, I've kept the magic numbers the same as in the NumPy impl (made a note here https://github.com/numba/numba/pull/2777/files#diff-4b9c6924f184d92f076cc50b84bcc442R1512). Good idea RE the IntEnum, will add one with members based on the strings for mode to enumerate the magic numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh and 1 is skipped as the mode same is not in use at present. :)

Respond to review comments.
@stuartarchibald
Copy link
Contributor Author

@sklam fixes done. Thanks for the review.

@seibert seibert merged commit 35d2977 into numba:master Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants