Skip to content

Commit

Permalink
Better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
AsgerHB committed Mar 27, 2024
1 parent 48c2c5e commit b448ad1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/BarbaricReachability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ function draw_barbaric_transition!(model,
colors=(:black, :gray),
plotargs...)

ix, iy = indexof((==(Colon())), slice)

ix, iy = 0, 0
if 1 == count((==(Colon())), slice)
ix = iy = 1
elseif 2 != count((==(Colon())), slice)
throw(ArgumentError("The slice argument should be an array of indices and exactly two colons. Example: [:, 10, :]"))
else
ix, iy = indexof((==(Colon())), slice)
end

samples = [s for s in SupportingPoints(model.samples_per_axis, partition)]
scatter!([s[ix] for s in samples], [s[iy] for s in samples],
Expand Down
2 changes: 1 addition & 1 deletion src/Grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function box(grid::Grid, state)

for dim in 1:grid.dimensions
if !(grid.bounds.lower[dim] <= state[dim] < grid.bounds.upper[dim])
throw(ArgumentError("State is out of bounds for this grid"))
throw(ArgumentError("State $state is outside this grid's bounds $(grid.bounds)"))
end

indices[dim] = floor(Int, (state[dim] - grid.bounds.lower[dim])/grid.granularity[dim]) + 1
Expand Down

0 comments on commit b448ad1

Please sign in to comment.