EcoJulia / NeutralLandscapes.jl

Generation of neutral landscapes in Julia.
https://ecojulia.github.io/NeutralLandscapes.jl/dev/
MIT License
16 stars 2 forks source link

fix blend functions and add _label #31

Closed mkborregaard closed 3 years ago

codecov-io commented 3 years ago

Codecov Report

Merging #31 (91032f4) into main (7ba1ad0) will decrease coverage by 0.84%. The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##            main     #31      +/-   ##
========================================
- Coverage   8.33%   7.49%   -0.85%     
========================================
  Files         12      12              
  Lines        240     267      +27     
========================================
  Hits          20      20              
- Misses       220     247      +27     
Flag Coverage Δ
unittests 7.49% <0.00%> (-0.85%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/NeutralLandscapes.jl 100.00% <ø> (ø)
src/classify.jl 0.00% <0.00%> (ø)

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 7ba1ad0...91032f4. Read the comment docs.

mkborregaard commented 3 years ago

This should be good to be reviewed. Try and check some of the choices I made e.g. in terms of giving the labels random numbers. Here's how blend now works with a cluster

wave = rand(WaveSurface(0, 2), 200, 200)
sources = unique(rand(1:40000, 10))
clust = NeutralLandscapes.classify!(rand(DistanceGradient(sources), (200, 200)), [0.5, 1, 1, 0.5])
res = blend(clust, wave)
plot(
       heatmap(wave),
       heatmap(clust),
       heatmap(res),
       size = (1400, 350), layout = (1,3)
)

blend

And this is the label function in action itself

heatmap(label(clust)[1], fillcolor = :picasso)

ret

I really struggled with debugging this one - fun challenge but pretty happy to have the PR made. label(clust) in the example runs in 51 ms on my laptop.