`random_nearby_position()` might return out-of-bounds positions
Closed this issue · 3 comments
Describe the bug
I found that the random_nearby_position()
function returned out-of-bounds positions when I failed to run the event ABM example.
Minimal Working Example
https://github.com/sosiristseng/agents-out-of-bounds/blob/main/main.jl
The results: https://github.com/sosiristseng/agents-out-of-bounds/actions/runs/8627726973/job/23648255748
Agents.jl version
Agents v6.0.7
Digging deeper, I found that IteratorSampling.jl might return an out-of-bound output when given an empty iterator. Maybe this issue should be transferred there.
iter = nearby_positions(model[1], model, 1)
iter_filtered = Iterators.filter(pos -> isempty(pos, model), iter)
# If I run collect(iter_filtered), it will return an empty array
# Returns a random, maybe out-of-bound output
IteratorSampling.itsample(abmrng(model), iter_filtered; method=:alg_R)
my mistake :q
I made it during a major overall of the IteratorSampling library, should be fixed by JuliaDynamics/StreamSampling.jl#48
@Tortar thank you for your reply. It's resolved after IteratorSampling v0.2.10.
https://github.com/sosiristseng/agents-out-of-bounds/actions/runs/8628924786/job/23652013609