Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar committed Oct 6, 2023
1 parent d483e68 commit 0f97544
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/submodules/io/jld2_integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ JLD2.wconvert(::Type{SerializableAStar{D,P,M,T,C}}, t::Pathfinding.AStar{D,P,M,T
)

function from_serializable(t::SerializableABM{S,A}; kwargs...) where {S,A}
abm = StandardABM(
abm = SingleContainerABM(
A,
from_serializable(t.space; kwargs...),
container = t.agents_container,
Expand Down
9 changes: 4 additions & 5 deletions test/randomness_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ end
@testset "sample!" begin
rng = StableRNG(50)
model4 = StandardABM(Agent1, GridSpace((2, 2)); rng = rng, warn_deprecation = false)
agents = allagents(model4)
add_agent!((1,1), Agent1, model4)
add_agent!((2,2), Agent1, model4)
sample!(model4, 4)
res = Dict{Int64, Agent1}(4 => Agent1(4, (2, 2)), 2 => Agent1(2, (2, 2)),
3 => Agent1(3, (2, 2)), 1 => Agent1(1, (1, 1)))
res_fields = [getfield(res[k], f) for f in fieldnames(Agent1) for k in keys(res)]
agents_fields = [getfield(agents[k], f) for f in fieldnames(Agent1) for k in keys(allagents(model4))]
@test keys(allagents(model4)) == keys(res)
agents_fields = [getfield(a, f) for f in fieldnames(Agent1) for a in allagents(model4)]
@test allids(model4) == keys(res)
@test res_fields == agents_fields
sample!(model4, 2)
res = Dict{Int64, Agent1}(4 => Agent1(4, (2, 2)), 1 => Agent1(1, (1, 1)))
res_fields = [getfield(res[k], f) for f in fieldnames(Agent1) for k in keys(res)]
agents_fields = [getfield(agents[k], f) for f in fieldnames(Agent1) for k in keys(allagents(model4))]
@test keys(allagents(model4)) == keys(res)
agents_fields = [getfield(a, f) for f in fieldnames(Agent1) for a in allagents(model4)]
@test allids(model4) == keys(res)
@test res_fields == agents_fields

rng = StableRNG(42)
Expand Down

0 comments on commit 0f97544

Please sign in to comment.