Commit 5614f4ca authored by Victor's avatar Victor

bug fixes

parent 59ffaf32
Pipeline #75035 passed with stage
in 21 minutes and 21 seconds
......@@ -50,19 +50,28 @@ update_clock!(w::World{A,S,T},dt) where {A,S,T} = begin
return nothing
end
#TODO : modify this
"""
$(SIGNATURES)
"""
get_geo(w::World) = map(a-> get_geo(a,time(w)), agents(w))
"""
$(SIGNATURES)
Returns trait of every agents of world in the form of an array which dimensions corresponds to the input.
If `trait = 0` , we return the geotrait.
# Warning
This works only for linear subspace, indexed with a single value
!!! warning "Warning"
Geotrait might be deprecated in the future.
"""
function get_x(w::World,trait)
if ndims(space(w)[trait]) > 1
hcat(collect.(getindex.(agents(w),trait))...)'
if !(trait == 0)
if ndims(space(w)[trait]) > 1
return hcat(collect.(getindex.(agents(w),trait))...)'
else
return collect(getindex.(agents(w),trait))
end
else
collect(getindex.(agents(w),trait))
return collect(get_geo(w))
end
end
......@@ -71,8 +80,8 @@ $(SIGNATURES)
Returns every traits of every agents of `world` in the form **of a one dimensional array** (in contrast to `get_x`).
If `geotrait=true` the geotrait is also added to the set of trait, in the last column.
If you do not want to specify `t` (only useful for geotrait), it is also possible to use `get_xarray(world::Array{T,1}) where {T <: Agent}`.
# Warning
It does not work with subspace where ndims(subspace) > 1.
!!! warning "Warning"
It does not work with subspace where ndims(subspace) > 1.
"""
function get_xarray(world::World,geotrait::Bool=false)
xarray = get_x(world,Colon())
......@@ -82,8 +91,3 @@ function get_xarray(world::World,geotrait::Bool=false)
return xarray
end
@deprecate get_xarray(world,geotrait=false) get_x(world,Colon())
"""
$(SIGNATURES)
"""
get_geo(w::World) = map(a-> get_geo(a,time(w)), agents(w))
......@@ -6,13 +6,13 @@ myspace1 = (RealSpace{1,Float64}(),)
myspace2 = (RealSpace{1,Float64}(),RealSpace{1,Float64}())
myspace3 = (DiscreteSegment(Int16(1),Int16(10)),RealSpace{1,Float64}())
g = SimpleGraph(1000,4000)
myspace4 = (GraphSpace(g),)
myspace4 = (RealSpace{1,Float64}(),GraphSpace(g),)
K0 = 1000; σ = 1e-1
a1 = [Agent(myspace1, (σ,) .* randn() .- .5,ancestors=true) for i in 1:K0]
a2 = [Agent(myspace2,tuple((σ, σ) .* randn(2) .- .5...),ancestors=true) for i in 1:K0]
a3 = [Agent(myspace3, (rand(Int16.(1:10)), 1e-1* randn() + 5.5 ),ancestors=true) for i in 1:K0]
a4 = [Agent(myspace4, (rand(Int64(1):Int64(1000)),),ancestors=true) for i in 1:K0]
a4 = [Agent(myspace4, (1.,rand(Int64(1):Int64(1000)),),ancestors=true) for i in 1:K0]
D = (1.,);
mu = [1.,1.]
......@@ -22,7 +22,7 @@ D = (1.,1.);
p2 = Dict{String,Any}();@pack! p2 = D,mu,NMax
D = (Int16(0.),0.)
p3 = Dict{String,Any}();@pack! p3 = D,mu,NMax
D = (0.)
D = (0.,0.)
p4 = Dict{String,Any}();@pack! p4 = D,mu,NMax
w1 = World(a1,myspace1,p1)
......@@ -36,6 +36,8 @@ w4 = World(a4,myspace4,p4)
@test first(var(w1)) (σ).^2 atol=0.001
@test first(var(w2,trait=2)) (σ).^2 atol=0.001
@test first(var(w4,trait=1)) < Inf
@test first(var(w4,trait=2)) < Inf
end
......
......@@ -4,8 +4,8 @@ using Revise,ABMEv
using UnPack
myspace = (GraphSpace(SimpleGraph(10,10)),RealSpace{1,Float64}())
myagents = [Agent(myspace,ancestors=true,rates=true) for i in 1:10]
d(X,Y) = gaussian(X[1],Y[1],1)
b(X,Y) = gaussian(X[1],0,1)
d(X,Y,t) = gaussian(X[1],Y[1],1)
b(X,Y,t) = gaussian(X[1],0,1)
D = (Int64(1),Float64(1.))
mu = [1,1]
NMax = 100
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment