JuliaGraphics / Colors.jl

Color manipulation utilities for Julia
Other
200 stars 44 forks source link

Optimize `distinguishable_colors` #506

Closed kimikage closed 2 years ago

kimikage commented 2 years ago

This changes the type used for internal operations from Lab{Float64} to Lab{Float32}. This also removes the unnecessary sRGB gamma operations and deleteat!.

Note that @nospecialize is almost useless because of the keyword arguments.

julia> @btime distinguishable_colors(10);
  10.832 ms (896527 allocations: 14.88 MiB) # master w/o recompilation
  5.104 ms (50998 allocations: 1.50 MiB)    # master w/ recompilation
  2.675 ms (9070 allocations: 213.08 KiB)   # this PR

Closes #477

codecov[bot] commented 2 years ago

Codecov Report

Merging #506 (ea591e3) into master (f71d7a1) will increase coverage by 1.49%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #506      +/-   ##
==========================================
+ Coverage   93.84%   95.34%   +1.49%     
==========================================
  Files           9        9              
  Lines        1154     1160       +6     
==========================================
+ Hits         1083     1106      +23     
+ Misses         71       54      -17     
Impacted Files Coverage Δ
src/colormaps.jl 98.13% <100.00%> (+3.08%) :arrow_up:
src/conversions.jl 99.38% <100.00%> (+<0.01%) :arrow_up:
src/utilities.jl 98.25% <0.00%> (-0.44%) :arrow_down:
src/algorithms.jl 75.00% <0.00%> (+14.04%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f71d7a1...ea591e3. Read the comment docs.

kimikage commented 2 years ago

BTW, the syntax for static parameters in the documentation is still outdated. https://github.com/JuliaGraphics/Colors.jl/blame/f7fddbd3f84df60eb4a667428a900e121309f150/docs/src/colormapsandcolorscales.md#L220-L232