From 3338624f984bab6e3ae3e834cc4f19acc41671bb Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:04:45 +0200 Subject: [PATCH] Remove redundant argument for initfields! --- src/core/simulation.jl | 2 +- src/crop/cropmodels.jl | 4 ++-- test/landscape_tests.jl | 3 +-- test/runtests.jl | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/simulation.jl b/src/core/simulation.jl index b3e4cf0..ac9a457 100644 --- a/src/core/simulation.jl +++ b/src/core/simulation.jl @@ -140,7 +140,7 @@ function initmodel(settings::Dict{String, Any}) ) saveinputfiles(model) - initfields!(model, settings["crop.cropmodel"]) + initfields!(model) initfarms!(model) initnature!(model) model diff --git a/src/crop/cropmodels.jl b/src/crop/cropmodels.jl index f175b9f..0cc9477 100644 --- a/src/crop/cropmodels.jl +++ b/src/crop/cropmodels.jl @@ -24,7 +24,7 @@ end Initialise the model with its farm plots. """ -function initfields!(model::SimulationModel, cropmodel::AbstractString) +function initfields!(model::SimulationModel) n = 0 convertid = Dict{Int64,Int64}() width, height = size(model.landscape) @@ -40,7 +40,7 @@ function initfields!(model::SimulationModel, cropmodel::AbstractString) model.landscape[x,y].fieldid = objectid push!(model.farmplots[objectid].pixels, (x,y)) else - cropstate = make_cropstate(model, cropmodel) + cropstate = make_cropstate(model, @param(crop.cropmodel)) fp = FarmPlot( length(model.farmplots) + 1, [(x, y)], diff --git a/test/landscape_tests.jl b/test/landscape_tests.jl index d2d3f02..b825765 100644 --- a/test/landscape_tests.jl +++ b/test/landscape_tests.jl @@ -6,8 +6,7 @@ @testset "Landscape initialisation" begin model = inittestmodel(false) # these tests are specific to the Jena maps - cropmodel = "almass" - @test_logs (:info, "Initialised 2092 farm plots.") match_mode=:any Ps.initfields!(model, cropmodel) + @test_logs (:info, "Initialised 2092 farm plots.") match_mode=:any Ps.initfields!(model) @test size(model.landscape) == (1754, 1602) @test Ps.landcover((100,100), model) == Ps.forest @test Ps.landcover((300,1), model) == Ps.soil diff --git a/test/runtests.jl b/test/runtests.jl index e826c76..4aaf78e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -43,7 +43,7 @@ function inittestmodel(smallmap=true) TESTSETTINGS["world.weatherfile"]), TESTSETTINGS["core.startdate"], TESTSETTINGS["core.enddate"]) - # TODO: allow init of other crop models besides ALMaSS + # TODO: support other crop models besides ALMaSS crops = Ps.ALMaSS.readcropparameters(TESTSETTINGS["crop.cropfile"], TESTSETTINGS["crop.growthfile"]) farmers = Vector{Farmer}() -- GitLab