Skip to content

Commit

Permalink
Fix out-of-bounds inspection of 2d plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Oct 10, 2024
1 parent fbb208d commit a32e8b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ext/AgentsVisualizations/src/spaces/grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ end

## Inspection

Agents.convert_element_pos(::S, pos) where {S<:Agents.AbstractGridSpace} =
Tuple(round.(Int, pos)) # using round to handle positions with offset

function Agents.convert_element_pos(s::S, pos) where {S<:Agents.AbstractGridSpace}
gridpos = pos[1:length(spacesize(s))]
Tuple(round.(Int, gridpos)) # using round to handle positions with offset
end
function Agents.ids_to_inspect(model::ABM{<:GridSpaceSingle}, pos)
id = id_in_position(pos, model)
return id == 0 ? () : (id,)
Expand Down

0 comments on commit a32e8b7

Please sign in to comment.