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
Further refactor spline filters #20519
Open
ev-br
wants to merge
39
commits into
scipy:main
Choose a base branch
from
ev-br:splinemodule_cpp
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
…e and fix initial state handling
Compare to what scipy 1.9.1 / numpy 1.20.x returns
The test exercises spline_filter of complex argument, and has useful info about spline_filter working in single precision for complex inputs (the reason is still unclear).
- merge _splines.py and _bsplines.py - merge tests/test_splines.py and tests/test_bsplines.py - rename the merged implementation file into _spline_filters.py None of this is user visible.
Run `$ clang-format -i ` on both files with .clang-format from scipy/special/special
github-actions
bot
added
C/C++
Items related to the internal C/C++ code base
Meson
Items related to the introduction of Meson as the new build system for SciPy
labels
Apr 18, 2024
It looks good to me! Thanks @ev-br |
(availablity of M_PI and PyArray_MIN varies by the system etc)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C/C++
Items related to the internal C/C++ code base
maintenance
Items related to regular maintenance tasks
Meson
Items related to the introduction of Meson as the new build system for SciPy
scipy.signal
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.
Reference issue
Based off #18926, will need a rebase when that one lands.
Supersedes and closes #14558
closes #13643
I initially meant to fix #9209, but turns out it is better addressed separately.
#12691 is related, but no change to it in this PR.
What does this implement/fix?
_splinemodule
from tempita-templated C into C++;#ifdef GNUC
guards_splines.py
and_bsplines.py
. Previously it was not clear what is where and why; The resulting python module is under 1kLOC, so it's OK, I think;sepfir2d
andspline_filter
.Additional information
This is pure maintenance in the end. I think it makes sense to land this separately from gh-18926: the latter does non-trivial algorithmic improvements, and this one just shuffles code around.
The main improvement is probably the complex-valued arithmetics: #13643 was due to the implementation probably predating C99; this PR uses standard tools instead; the python <-> C++ glue parrots what scipy.special does (thanks @steppi for the explanation!).
Here's a bigger picture, as far as I understand it:
signal.spline_filter
is IIUC used for image denoisingsignal.symirrorder{1,2}
andsignal.sepfir2d
symiirorder
filters in ENH: Move symiirorder1/2, cspline2d, qspline2d and spline_filter to use sosfilt/lfilter #18926 to uselfilter
/sosfilt
instead of... uhm... bespoke manual implementations from the multipack era.sepfir2d
is still using C code from 2003, only minimally modernized.A larger clean-up of
sepfir2d
could be to take a look at what CuPy does: it delegates a large chunk ofsignal
convolution/filtering tondimage
(https://github.com/cupy/cupy/blob/v13.0.0/cupyx/scipy/signal/_bsplines.py#L72). Maybe SciPy can follow suit and remove a large amount of C code in scipy.signal.Note that this is where gh-13643 originates.
This will require figuring out what CuPy actually does, and a careful testing, benchmarking etc etc. So it's a somewhat sizeable project, and is best done separately.