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
a8280064
Commit
a8280064
authored
8 months ago
by
Marco Matthies
Browse files
Options
Downloads
Patches
Plain Diff
Fixes for SimpleCrop unit tests
parent
79d17c15
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/crop/cropmodels.jl
+2
-1
2 additions, 1 deletion
src/crop/cropmodels.jl
src/crop/simplecrop.jl
+11
-3
11 additions, 3 deletions
src/crop/simplecrop.jl
test/crop_tests.jl
+1
-1
1 addition, 1 deletion
test/crop_tests.jl
with
14 additions
and
5 deletions
src/crop/cropmodels.jl
+
2
−
1
View file @
a8280064
...
@@ -18,7 +18,8 @@ function initcropmodel(cropmodel::AbstractString, cropfile::AbstractString, grow
...
@@ -18,7 +18,8 @@ function initcropmodel(cropmodel::AbstractString, cropfile::AbstractString, grow
Tcroptype
=
SimpleCrop
.
CropType
Tcroptype
=
SimpleCrop
.
CropType
Tcropstate
=
SimpleCrop
.
CropState
Tcropstate
=
SimpleCrop
.
CropState
crops_almass
=
ALMaSS
.
readcropparameters
(
cropfile
,
growthfile
)
crops_almass
=
ALMaSS
.
readcropparameters
(
cropfile
,
growthfile
)
crops
=
Dict
(
name
=>
SimpleCrop
.
CropType
(
ct
.
name
)
for
(
name
,
ct
)
in
crops_almass
)
crops
=
Dict
(
name
=>
SimpleCrop
.
CropType
(
ct
.
name
,
ct
.
group
,
ct
.
minsowdate
,
ct
.
maxsowdate
)
for
(
name
,
ct
)
in
crops_almass
)
else
else
error
(
"initcropmodel: no implementation for crop model '
$
cropmodel'"
)
error
(
"initcropmodel: no implementation for crop model '
$
cropmodel'"
)
end
end
...
...
This diff is collapsed.
Click to expand it.
src/crop/simplecrop.jl
+
11
−
3
View file @
a8280064
module
SimpleCrop
module
SimpleCrop
using
Persefone
:
using
Persefone
:
AnnualDate
,
FarmPlot
,
FarmPlot
,
Length
,
Length
,
cm
,
cm
,
...
@@ -14,10 +15,17 @@ import Persefone:
...
@@ -14,10 +15,17 @@ import Persefone:
cropcover
,
cropcover
,
cropyield
,
cropyield
,
sow!
,
sow!
,
harvest!
harvest!
,
isharvestable
using
Unitful
:
@u_str
# TODO: alternatively just use ALMaSS.CropType ?
struct
CropType
struct
CropType
name
::
String
name
::
String
group
::
String
minsowdate
::
Union
{
Missing
,
AnnualDate
}
maxsowdate
::
Union
{
Missing
,
AnnualDate
}
end
end
cropname
(
ct
::
CropType
)
=
ct
.
name
cropname
(
ct
::
CropType
)
=
ct
.
name
...
@@ -64,8 +72,8 @@ function harvest!(cs::CropState, model::SimulationModel)
...
@@ -64,8 +72,8 @@ function harvest!(cs::CropState, model::SimulationModel)
# TODO: set cs.croptype ?
# TODO: set cs.croptype ?
# TODO: this 1.0g/cm/m^2 height_to_yield factor should be a param
# TODO: this 1.0g/cm/m^2 height_to_yield factor should be a param
# for every crop type
# for every crop type
yield
=
cs
.
height
*
1.0
g
/
cm
/
m
^
2
yield
=
cs
.
height
*
1.0
u
"
g/cm/m^2
"
cs
.
height
=
0
cm
cs
.
height
=
5.
0
cm
return
yield
return
yield
end
end
...
...
This diff is collapsed.
Click to expand it.
test/crop_tests.jl
+
1
−
1
View file @
a8280064
...
@@ -38,7 +38,7 @@ end
...
@@ -38,7 +38,7 @@ end
end
end
@testset
"Submodule SimpleCrop"
begin
@testset
"Submodule SimpleCrop"
begin
ct
=
Ps
.
SimpleCrop
.
CropType
(
"olive tree"
)
ct
=
Ps
.
SimpleCrop
.
CropType
(
"olive tree"
,
"no_crop_group"
,
AnnualDate
(
4
,
1
),
AnnualDate
(
5
,
1
)
)
id
=
0
id
=
0
pixels
=
[(
0
,
0
)]
pixels
=
[(
0
,
0
)]
farmer
=
0
farmer
=
0
...
...
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