From 02a6d848500fffbd44238b1b8ccff7d6583efea3 Mon Sep 17 00:00:00 2001 From: Ludmilla Figueiredo <ludmilla.figueiredo@idiv.de> Date: Wed, 12 Apr 2023 13:07:54 +0200 Subject: [PATCH] first code review (details in issues #40) --- src/analysis/analyse_nature.R | 2 +- src/core/input.jl | 6 +++++- src/core/output.jl | 2 +- src/nature/populations.jl | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/analysis/analyse_nature.R b/src/analysis/analyse_nature.R index c176b9f..e63027a 100755 --- a/src/analysis/analyse_nature.R +++ b/src/analysis/analyse_nature.R @@ -23,7 +23,7 @@ map_output_file = "landscape_map" populationTrends = function() { print("Plotting population trends over time.") popdata = read.csv2(paste(datadir, popfile, sep="/")) %>% - mutate(Date = as.POSIXct(strptime(Date,format="%Y-%m-%d"))) + mutate(Date = as.POSIXct(strptime(Date, format="%Y-%m-%d"))) ggplot(data=popdata, aes(x=Date, y=Abundance, color=Species)) + geom_point() + ##geom_smooth() + diff --git a/src/core/input.jl b/src/core/input.jl index b373048..3b4f25b 100644 --- a/src/core/input.jl +++ b/src/core/input.jl @@ -32,6 +32,10 @@ macro param(domainparam) end """ + getsettings(configfile::String, seed::Union{Int64,Nothing}=nothing) + # VScode suggested to "Update method signature in docstring" + # I leave it up to you to decide if you want to do it for all the functions. + getsettings(configfile, seed=nothing) Combines all configuration options to produce a single settings dict. @@ -95,7 +99,7 @@ function preprocessparameters(settings::Dict{String,Any}, defaultoutdir::String) end """ - flattenTOML(dict) + flattenTOML(tomldict) An internal utility function to convert the two-dimensional dict returned by `TOML.parsefile()` into a one-dimensional dict, so that instead of diff --git a/src/core/output.jl b/src/core/output.jl index b805608..f5a7a41 100644 --- a/src/core/output.jl +++ b/src/core/output.jl @@ -98,7 +98,7 @@ function saveinputfiles(model::AgentBasedModel) end """ - prepareTOML(dict) + prepareTOML(settings) An internal utility function to re-convert the one-dimensional dict created by [`flattenTOML`](@ref) into the two-dimensional dict needed by `TOML.print`, diff --git a/src/nature/populations.jl b/src/nature/populations.jl index 12188a2..a585d9d 100644 --- a/src/nature/populations.jl +++ b/src/nature/populations.jl @@ -5,7 +5,7 @@ ### """ - initpopulation(habitatdescriptor; popsize=-1, pairs=false, asexual=false) + initpopulation(habitatdescriptor; popsize=-1, phase= nothing, pairs=false, asexual=false) Creates a function that initialises individuals at random locations across the landscape. This can be used to create the `initialise!` variable in a species definition block. @@ -27,7 +27,7 @@ This can be used to create the `initialise!` variable in a species definition bl location, otherwise, only one individual will be created at a time. - If `asexual` is true, all created individuals are assigned the sex `hermaphrodite`, - otherwise, they are randomly assigned male of female. (If `pairs` is true, `asexual` + otherwise, they are randomly assigned male or female. (If `pairs` is true, `asexual` is ignored.) """ function initpopulation(habitatdescriptor::Function; phase::Union{String,Nothing}=nothing, -- GitLab