colour-science / colour

Colour Science for Python
https://www.colour-science.org
BSD 3-Clause "New" or "Revised" License
2.03k stars 257 forks source link

PR: Improve performance of SpragueInterpolator #1268

Closed tjdcs closed 3 weeks ago

tjdcs commented 1 month ago

SpragueInterpolator is the default interpolator for SpectralDistribution 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.

tjdcs commented 1 month ago

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.

tjdcs commented 1 month ago

@KelSolaar the failing tests are doctest(s) in generation.py. Do you have a prefered resolution? Should I add ellipses... or round... or something else? Seems like the explicit tests are passing within the tolerance we expect / use.

KelSolaar commented 1 month ago

Hey @tjdcs,

Thanks a lot! Yeah ellipsis would be absolutely fine here.

Cheers,

Thomas

tjdcs commented 1 month ago

@KelSolaar looks like these are all passing now. Should be g2g when the last few tasks finish.

coveralls commented 1 month ago

Coverage Status

coverage: 99.978%. remained the same when pulling 94f34ae314238f997e8c2d62d903d1d34562af6e on performance/interpolation into 9fe1fdf2bc54935559af8094eec3b012fd001065 on develop.