Update signal::convolve to use ndarrays over vec#76
Draft
SpookyYomo wants to merge 4 commits intoqsib-cbie:mainfrom
Draft
Update signal::convolve to use ndarrays over vec#76SpookyYomo wants to merge 4 commits intoqsib-cbie:mainfrom
SpookyYomo wants to merge 4 commits intoqsib-cbie:mainfrom
Conversation
Scipy's documentation specifies that convolve (by FFT) accepts N-dimensional numpy arrays, and not just 1D. This commit provides some progress towards the interface standardisation. Due to trait bounds, either both arguments have to be by reference, or by value. To make things easier for end users, we let the functions be by reference, so that rust vectors in-place of ndarray::Array1 is also accepted by our functions.
Symmetric kernel meant that it was possible that it was not properly checked.
2426c05 to
dfc02e0
Compare
dfc02e0 to
d533625
Compare
While this rejects taking in of Vec, it simplifies the function signature a lot, and allows for clearer expression by end user if to pass ndarrays by value or reference.
This makes the type signature easier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overarching theme:
This PR is part of a larger effort to ensure ability to accept N-dimensional arrays over rust vecs.
PR details:
We defer to the communities efforts in NDArray FFT convolution instead of reinventing the wheel. There also exists other crates such as
fftconvolve, but due to licensing, we go withndarray-conv.We try our best to make it convenient for users, so we use
impl Into<ArrayView<_, _>>orimpl Into<ArrayBase<_, _>>, so that rust vectors and slices besidesArrayBasecan also be accepted by the function.References:
ConvFFTExt differences from Scipy.
Trait bounds in thin wrapping. Special thanks to ndarray-conv creator for the help so far.
Todos before merging this PR:
Other details:
For unspecified dimensions,
array[:, -1]as in python cannot satisfy NDArray trait bounds by doingarray.slice(s![..;-1]).