Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
926de5c2
Commit
926de5c2
authored
11 months ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Upgraded tests to new code structure (except nature tests)
parent
8a958fd9
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
test/io_tests.jl
+3
-7
3 additions, 7 deletions
test/io_tests.jl
test/landscape_tests.jl
+6
-1
6 additions, 1 deletion
test/landscape_tests.jl
test/runtests.jl
+16
-16
16 additions, 16 deletions
test/runtests.jl
test/simulation_tests.jl
+2
-3
2 additions, 3 deletions
test/simulation_tests.jl
with
27 additions
and
27 deletions
test/io_tests.jl
+
3
−
7
View file @
926de5c2
...
@@ -4,11 +4,7 @@
...
@@ -4,11 +4,7 @@
###
###
@testset
"Model configuration"
begin
@testset
"Model configuration"
begin
settings
=
Ps
.
getsettings
(
TESTPARAMETERS
)
model
=
inittestmodel
()
properties
=
Dict
{
Symbol
,
Any
}(
:
settings
=>
settings
)
space
=
GridSpace
((
10
,
10
),
periodic
=
false
)
model
=
SimulationModel
(
Animal
,
space
,
properties
=
properties
,
warn
=
false
)
@test
@param
(
core
.
configfile
)
==
basename
(
TESTPARAMETERS
)
@test
@param
(
core
.
configfile
)
==
basename
(
TESTPARAMETERS
)
@test
@param
(
core
.
startdate
)
==
Date
(
2022
,
2
,
1
)
@test
@param
(
core
.
startdate
)
==
Date
(
2022
,
2
,
1
)
@test
@param
(
core
.
loglevel
)
==
"warn"
@test
@param
(
core
.
loglevel
)
==
"warn"
...
@@ -76,11 +72,11 @@ end
...
@@ -76,11 +72,11 @@ end
model2
=
loadmodelobject
(
joinpath
(
@param
(
core
.
outdir
),
"test.dat"
))
model2
=
loadmodelobject
(
joinpath
(
@param
(
core
.
outdir
),
"test.dat"
))
@test
model
.
date
==
model2
.
date
@test
model
.
date
==
model2
.
date
@test
model
.
settings
==
model2
.
settings
@test
model
.
settings
==
model2
.
settings
@test
length
(
model
.
agents
)
==
length
(
model2
.
agents
)
@test
Ps
.
nagents
(
model
)
==
Ps
.
nagents
(
model2
)
simulate!
(
Ps
.
withtestlogger
(
model
))
simulate!
(
Ps
.
withtestlogger
(
model
))
simulate!
(
Ps
.
withtestlogger
(
model2
))
simulate!
(
Ps
.
withtestlogger
(
model2
))
@test
model
.
date
==
model2
.
date
@test
model
.
date
==
model2
.
date
@test
length
(
model
.
agents
)
==
length
(
model2
.
agents
)
@test
Ps
.
nagents
(
model
)
==
Ps
.
nagents
(
model2
)
rm
(
@param
(
core
.
outdir
),
force
=
true
,
recursive
=
true
)
rm
(
@param
(
core
.
outdir
),
force
=
true
,
recursive
=
true
)
@param
(
core
.
enddate
)
=
originalenddate
@param
(
core
.
enddate
)
=
originalenddate
end
end
...
...
This diff is collapsed.
Click to expand it.
test/landscape_tests.jl
+
6
−
1
View file @
926de5c2
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
@test
Ps
.
landcover
((
1100
,
1100
),
model
)
==
Ps
.
builtup
@test
Ps
.
landcover
((
1100
,
1100
),
model
)
==
Ps
.
builtup
@test
Ps
.
averagefieldsize
(
model
)
==
5.37
@test
Ps
.
averagefieldsize
(
model
)
==
5.37
@test
count
(
f
->
ismissing
(
f
.
fieldid
),
model
.
landscape
)
==
1685573
@test
count
(
f
->
ismissing
(
f
.
fieldid
),
model
.
landscape
)
==
1685573
@test
length
(
Ps
.
farmplot
((
800
,
800
),
model
)
.
pixels
)
==
4049
@test
length
(
Ps
.
farmplot
((
800
,
800
),
model
)
.
pixels
)
==
4049
end
end
@testset
"Event system"
begin
@testset
"Event system"
begin
...
@@ -42,6 +42,11 @@ end
...
@@ -42,6 +42,11 @@ end
@testset
"Landscape functions"
begin
@testset
"Landscape functions"
begin
model
=
inittestmodel
()
model
=
inittestmodel
()
@test
Ps
.
directionto
((
2
,
3
),
model
,
Ps
.
agriculture
)
==
(
0
,
0
)
@test
Ps
.
directionto
((
2
,
3
),
model
,
Ps
.
forest
)
==
(
-
1
,
2
)
@test
Ps
.
directionto
((
2
,
3
),
model
,
Ps
.
grass
)
==
(
1
,
2
)
@test
Ps
.
directionto
((
2
,
3
),
model
,
Ps
.
water
)
==
(
4
,
1
)
@test
Ps
.
directionto
((
2
,
3
),
model
,
Ps
.
soil
)
==
nothing
@test
Ps
.
distanceto
((
2
,
3
),
model
,
Ps
.
agriculture
)
==
0
@test
Ps
.
distanceto
((
2
,
3
),
model
,
Ps
.
agriculture
)
==
0
@test
Ps
.
distanceto
((
2
,
3
),
model
,
Ps
.
forest
)
==
2
@test
Ps
.
distanceto
((
2
,
3
),
model
,
Ps
.
forest
)
==
2
@test
Ps
.
distanceto
((
2
,
3
),
model
,
Ps
.
grass
)
==
2
@test
Ps
.
distanceto
((
2
,
3
),
model
,
Ps
.
grass
)
==
2
...
...
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
16
−
16
View file @
926de5c2
...
@@ -39,20 +39,20 @@ function inittestmodel(smallmap=true)
...
@@ -39,20 +39,20 @@ function inittestmodel(smallmap=true)
TESTSETTINGS
[
"core.enddate"
])
TESTSETTINGS
[
"core.enddate"
])
crops
=
Ps
.
readcropparameters
(
TESTSETTINGS
[
"crop.cropfile"
],
crops
=
Ps
.
readcropparameters
(
TESTSETTINGS
[
"crop.cropfile"
],
TESTSETTINGS
[
"crop.growthfile"
])
TESTSETTINGS
[
"crop.growthfile"
])
model
=
Simulation
Model
(
TESTSETTINGS
,
model
=
Agriculture
Model
(
TESTSETTINGS
,
StableRNG
(
TESTSETTINGS
[
"core.seed"
]),
StableRNG
(
TESTSETTINGS
[
"core.seed"
]),
global_logger
(),
global_logger
(),
Vector
{
DataOutput
}(),
Vector
{
DataOutput
}(),
Dict
{
String
,
DataFrame
}(),
Dict
{
String
,
DataFrame
}(),
TESTSETTINGS
[
"core.startdate"
],
TESTSETTINGS
[
"core.startdate"
],
landscape
,
landscape
,
weather
,
weather
,
crops
,
crops
,
Vector
{
Farmer
}(),
Vector
{
Farmer
}(),
Vector
{
FarmPlot
}(),
Vector
{
FarmPlot
}(),
Vector
{
Union
{
Animal
s
,
Nothing
}}(),
Vector
{
Union
{
Animal
,
Nothing
}}(),
Vector
{
Pair
{
Animal
,
Date
}}(),
Vector
{
Pair
{
Animal
,
Date
}}(),
Vector
{
FarmEvent
}())
Vector
{
FarmEvent
}())
model
model
end
end
...
@@ -78,10 +78,10 @@ function smalltestlandscape()
...
@@ -78,10 +78,10 @@ function smalltestlandscape()
(
x
in
(
1
:
2
))
?
lc
=
Ps
.
forest
:
(
x
in
(
1
:
2
))
?
lc
=
Ps
.
forest
:
(
y
==
8
)
?
lc
=
Ps
.
builtup
:
(
y
==
8
)
?
lc
=
Ps
.
builtup
:
lc
=
Ps
.
grass
lc
=
Ps
.
grass
landscape
[
x
,
y
]
=
Pixel
(
lc
,
missing
,
[])
landscape
[
x
,
y
]
=
Pixel
(
lc
,
missing
,
[],
[])
end
end
end
end
landscape
[
6
,
4
]
=
Pixel
(
Ps
.
water
,
0
,
[])
landscape
[
6
,
4
]
=
Pixel
(
Ps
.
water
,
0
,
[],
[])
landscape
landscape
end
end
...
...
This diff is collapsed.
Click to expand it.
test/simulation_tests.jl
+
2
−
3
View file @
926de5c2
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
@test
typeof
(
model
.
logger
)
==
TeeLogger
{
Tuple
{
ConsoleLogger
,
ConsoleLogger
}}
@test
typeof
(
model
.
logger
)
==
TeeLogger
{
Tuple
{
ConsoleLogger
,
ConsoleLogger
}}
@test
length
(
model
.
dataoutputs
)
==
2
@test
length
(
model
.
dataoutputs
)
==
2
@test
model
.
events
==
Vector
{
FarmEvent
}()
@test
model
.
events
==
Vector
{
FarmEvent
}()
@test
nagents
(
model
)
==
2092
+
10
+
28
@test
Ps
.
nagents
(
model
)
==
2092
+
10
+
28
#FIXME 2412 == 2130
end
end
@testset
"Parameter scanning"
begin
@testset
"Parameter scanning"
begin
...
@@ -48,8 +48,7 @@ end
...
@@ -48,8 +48,7 @@ end
rand1
=
rand
()
rand1
=
rand
()
Random
.
seed!
(
1
)
Random
.
seed!
(
1
)
model
=
initialise
(
TESTPARAMETERS
,
218
)
model
=
initialise
(
TESTPARAMETERS
,
218
)
#XXX upstream problem with ArgParse (https://github.com/carlobaldassi/ArgParse.jl/issues/121) - should work again with Julia 1.10
@test
rand
()
==
rand1
@test_broken
rand
()
==
rand1
Random
.
seed!
(
1
)
Random
.
seed!
(
1
)
@test
@param
(
core
.
seed
)
==
218
@test
@param
(
core
.
seed
)
==
218
@test_logs
((
:
info
,
"Simulating day 2022-02-01."
),
@test_logs
((
:
info
,
"Simulating day 2022-02-01."
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment