EcoJulia / NeutralLandscapes.jl

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

NearestNeighborCluser is broken with :queen #53

Closed rafaqz closed 3 years ago

rafaqz commented 3 years ago

Describe the bug

julia> rand(NearestNeighborCluster(; n=:queen), 100, 100)
ERROR: InexactError: Int64(-0.8399155691543502)
Stacktrace:
 [1] Int64(::Float64) at ./float.jl:710
 [2] label(::Array{Float64,2}, ::Symbol) at /home/raf/julia/NeutralLandscapes/src/classify.jl:118
 [3] _landscape!(::Array{Float64,2}, ::NearestNeighborCluster) at /home/raf/julia/NeutralLandscapes/src/algorithms/nncluster.jl:25
 [4] #rand!#3 at /home/raf/julia/NeutralLandscapes/src/landscape.jl:32 [inlined]
 [5] #rand#1 at /home/raf/julia/NeutralLandscapes/src/landscape.jl:20 [inlined]
 [6] #rand#2 at /home/raf/julia/NeutralLandscapes/src/landscape.jl:22 [inlined]
 [7] rand(::NearestNeighborCluster, ::Int64, ::Int64) at /home/raf/julia/NeutralLandscapes/src/landscape.jl:22
 [8] top-level scope at REPL[2]:1

Environment:

gottacatchenall commented 3 years ago

the :queen option causes it to read out of bounds, ugly but functional solution in #54

gottacatchenall commented 3 years ago

closed in #54