JuliaGraphics / ColorTypes.jl

Basic color definitions and traits
Other
78 stars 36 forks source link

Add `init` keyword support for `reducec` & `mapreducec` #263

Closed kimikage closed 3 years ago

kimikage commented 3 years ago

This also makes it possible to omit specifying the init value.

julia> rgb = rand(RGB, 1000, 1000);

julia> @btime reducec.(+, 0.2, rgb); # conventional
  1.746 ms (6 allocations: 7.63 MiB)

julia> @btime reducec.(+, rgb, init=0.2); # with `init`
  1.897 ms (13 allocations: 7.63 MiB)

julia> @btime reducec.(+, rgb); # omitting `init` (=`0.0`)
  1.883 ms (5 allocations: 7.63 MiB)

Closes #247

codecov[bot] commented 3 years ago

Codecov Report

Merging #263 (41d50f6) into master (bd4bad2) will increase coverage by 0.08%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #263      +/-   ##
==========================================
+ Coverage   83.80%   83.89%   +0.08%     
==========================================
  Files           8        8              
  Lines         735      739       +4     
==========================================
+ Hits          616      620       +4     
  Misses        119      119              
Impacted Files Coverage Δ
src/operations.jl 98.49% <100.00%> (+0.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 bd4bad2...41d50f6. Read the comment docs.

kimikage commented 3 years ago

After sorting out the handling of Number input, let's decide if we want to support multiple iterators. (cf. #207, https://github.com/JuliaGraphics/ColorTypes.jl/issues/247#issuecomment-824607503) The conventional style (v0) is also available for now.

johnnychen94 commented 3 years ago

I'm very much in favor of mapc/mapreducec with multiple iterators, it makes color types more like iterator without breaking their atomic/non-broadcastable property.