-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
PR: Improve performance of SpragueInterpolator #1268
Conversation
Two tests are failing =========================== short test summary info ============================
FAILED colour/colorimetry/generation.py::colour.colorimetry.generation.sd_gaussian
FAILED colour/colorimetry/generation.py::colour.colorimetry.generation.sd_gaussian_fwhm
===== 2 failed, 3464 passed, 11 skipped, 190 warnings in 185.65s (0:03:05) ===== However, my local environment passes these... :/ sneaky. Will investigate. |
@KelSolaar the failing tests are doctest(s) in |
Hey @tjdcs, Thanks a lot! Yeah ellipsis would be absolutely fine here. Cheers, Thomas |
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.
LGTM besides the einsum
usage, I think we need to get rid of the other usages in the codebase.
colour/algebra/interpolation.py
Outdated
# Fancy vector code here... use underlying numpy structures to accelerate | ||
# parts of the linear algebra. | ||
|
||
y = r[i] + np.einsum( | ||
"ab,ab->b", a.reshape(5, -1), X ** np.arange(1, 6).reshape(-1, 1) | ||
) |
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.
With the desire to move toward data-array API compliance and because Einstein Sum is not planned to be supported, we should try to rewrite this using lower level APIs: https://data-apis.org/array-api/latest/extensions/linear_algebra_functions.html
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.
I removed all usages of np.einsum
in develop
.
ea330ed
to
6500280
Compare
for more information, see https://pre-commit.ci
9dfdc08
to
94f34ae
Compare
@KelSolaar looks like these are all passing now. Should be g2g when the last few tasks finish. |
SpragueInterpolator
is the default interpolator forSpectralDistribution
making it a highly frequented code path. This PR greatly improves the performance of interpolation by using vectorized code and numpy.Other interpolators could be similarly sped up but they are lower priority.