Skip to content

Commit

Permalink
Validated input sizes for adjacency list
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Petukhov committed Apr 12, 2024
1 parent f32fe4b commit 7bb4c16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/processing/data_processing/boundary_estimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function boundary_polygons_from_grid(grid_labels::Matrix{<:Unsigned}; grid_step:
borders_per_label = grid_borders_per_label(grid_labels);
polys = Matrix{Float64}[]
for bords in borders_per_label
if size(bords, 1) == 0
if size(bords, 1) < 2
push!(polys, Float64[;;])
continue
end
Expand Down
5 changes: 5 additions & 0 deletions src/processing/data_processing/triangulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ function adjacency_list(
adjacency_type::Symbol=:auto, distance::TD where TD <: Distances.SemiMetric = Euclidean(),
return_tesselation::Bool=false
)
if size(points, 2) <= 1
!return_tesselation || error("Tesselation is not possible for less than 2 points")
return Matrix{Int}(undef, 2, 0), Vector{Float64}(undef, 0)
end

if adjacency_type == :auto
adjacency_type = (size(points, 1) == 3) ? :knn : :triangulation
end
Expand Down

0 comments on commit 7bb4c16

Please sign in to comment.