From bc2ac7210b1210a663d4eb119f17f95a1db50aa6 Mon Sep 17 00:00:00 2001 From: MOshima-PIFSC Date: Tue, 11 Jul 2023 18:24:44 +0000 Subject: [PATCH] style and docs: run devtools::document() and styler::style_pkg() --- DESCRIPTION | 74 ++++++++++++++---------------------- tests/testthat.R | 5 ++- tests/testthat/test-HCxval.R | 19 +++++---- tests/testthat/test-retro.R | 16 ++++---- 4 files changed, 49 insertions(+), 65 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4357147..47b3973 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,57 +2,41 @@ Package: ss3diags Title: Stock Synthesis Model Diagnostics for Intergated Stock Assessments Version: 2.1.1 Date: 2023-06-07 -Authors@R: - c(person(given = "Henning", - family = "Winker", - role = c("aut"), - email = "henning.winker@ec.europa.eu"), - person(given = "Felipe", - family = "Carvalho", - role = c("aut"), - email = "felipe.carvalho@noaa.gov"), - person(given = "Massimiliano", - family = "Cardinale", - role = c("aut"), - email = "massimiliano.cardinale@slu.se"), - person(given = "Laurence", - family = "Kell", - role = c("aut"), - email = "laurie@seaplusplus.co.uk"), - person(given = "Megumi", - family = "Oshima", - role = c("aut","cre"), - email = "megumi.oshima@noaa.gov"), - person(given = "Eric", - family = "Fletcher", - role = c("aut"), - email = "eric.fletcher@noaa") - ) -Description: Compilation of diagnostic functions for Stock Synthesis models, which - developed for the manuscript "Using Model Diagnostics in Integrated Stock Assessments". +Authors@R: c( + person("Henning", "Winker", , "henning.winker@ec.europa.eu", role = "aut"), + person("Felipe", "Carvalho", , "felipe.carvalho@noaa.gov", role = "aut"), + person("Massimiliano", "Cardinale", , "massimiliano.cardinale@slu.se", role = "aut"), + person("Laurence", "Kell", , "laurie@seaplusplus.co.uk", role = "aut"), + person("Megumi", "Oshima", , "megumi.oshima@noaa.gov", role = c("aut", "cre")), + person("Eric", "Fletcher", , "eric.fletcher@noaa", role = "aut") + ) +Description: Compilation of diagnostic functions for Stock Synthesis + models, which developed for the manuscript "Using Model Diagnostics in + Integrated Stock Assessments". +License: EUPL +URL: https://github.com/PIFSCstockassessments/ss3diags +BugReports: https://github.com/PIFSCstockassessments/ss3diags/issues Depends: - R (>= 3.5) + R (>= 3.5) Imports: - reshape2, - mvtnorm, - randtests, - r4ss(>= 1.46.1), + dplyr, gplots, + lifecycle, magrittr, - dplyr, - rlang, - lifecycle -Remotes: r4ss/r4ss#821 -License: EUPL + mvtnorm, + r4ss(>= 1.46.1), + randtests, + reshape2, + rlang +Suggests: + knitr, + markdown, + rmarkdown, + testthat (>= 3.0.0) +Remotes: + r4ss/r4ss#821 Encoding: UTF-8 LazyData: True LazyDataCompression: gzip Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 -Suggests: - testthat (>= 3.0.0), - knitr, - rmarkdown, - markdown -URL: https://github.com/PIFSCstockassessments/ss3diags -BugReports: https://github.com/PIFSCstockassessments/ss3diags/issues diff --git a/tests/testthat.R b/tests/testthat.R index fe14ff3..f17124c 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -9,11 +9,12 @@ dir.create(run_tmp, showWarnings = FALSE) file.copy(from = list.files(files_path, full.names = TRUE), to = run_tmp) ## Run retrospectives -if(file.exists(file.path(files_path, "ss")|file.path(files_path, "ss.exe"))){ +if (file.exists(file.path(files_path, "ss") | file.path(files_path, "ss.exe"))) { r4ss::retro(dir = run_tmp, oldsubdir = "", newsubdir = "retrospectives", years = 0:-3, show_in_console = FALSE) # Creating retrospective object here so that multiple test files can access it without having to re-run retrospective for each test retroModels <- r4ss::SSgetoutput( - dirvec = file.path(run_tmp, "retrospectives", + dirvec = file.path( + run_tmp, "retrospectives", paste0("retro", 0:-3) ) ) diff --git a/tests/testthat/test-HCxval.R b/tests/testthat/test-HCxval.R index 50be67a..d86dc18 100644 --- a/tests/testthat/test-HCxval.R +++ b/tests/testthat/test-HCxval.R @@ -9,8 +9,8 @@ dir.create(path, showWarnings = FALSE) ## Hindcast plotting of indices test_that("Hindcast plot is created for simple model indices", { - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) SSplotHCxval(retrosum.simple, @@ -41,11 +41,11 @@ test_that("Hindcast plot is created for simple model indices", { #### note: function was too complicated to replicate in the test script so used values directly from running the function. If code for calculations changes, the values will change and it will error or if the SS3 input files change, the values will be different and it will error. test_that("MASE table gives expected values for simple model", { - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) - + mase <- SSplotHCxval(retrosum.simple, add = T, verbose = F) expect_match(mase$Index[1], "SURVEY1") @@ -55,9 +55,8 @@ test_that("MASE table gives expected values for simple model", { test_that("SSretroComps returns the correct comp data for simple model", { - - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) retro_comps <- SSretroComps(retroSimple) @@ -72,8 +71,8 @@ test_that("SSretroComps returns the correct comp data for simple model", { test_that("SSmase base.adj changes", { - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) ssmase <- SSmase(retrosum.simple, MAE.base.adj = 0.15) diff --git a/tests/testthat/test-retro.R b/tests/testthat/test-retro.R index 79b3bd3..0272a80 100644 --- a/tests/testthat/test-retro.R +++ b/tests/testthat/test-retro.R @@ -6,8 +6,8 @@ dir.create(path, showWarnings = FALSE) ## SSB test_that("Retrospective plot is created for SSB (w/ deprecated parameters)", { - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) SSplotRetro(retrosum.simple, @@ -23,8 +23,8 @@ test_that("Retrospective plot is created for SSB (w/ deprecated parameters)", { ## F test_that("Retrospective plot is created for F (w/ deprecated parameters)", { - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) SSplotRetro(retrosum.simple, @@ -41,8 +41,8 @@ test_that("Retrospective plot is created for F (w/ deprecated parameters)", { ## Mohn's Rho table using SShcbias function. It's the same code used in SSplotRetro to make the table. ## SSB test_that("Mohn's Rho table is created for SSB", { - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) n <- retrosum.simple$n @@ -70,8 +70,8 @@ test_that("Mohn's Rho table is created for SSB", { ## F test_that("Mohn's Rho table is created for F", { - skip_if( - !exists("retrosum.simple") , + skip_if( + !exists("retrosum.simple"), message = "skipping test that requires SS3 executable" ) n <- retrosum.simple$n