From a5ee9f9a35cfb503a77059fb3a26410fc3fe2d4f Mon Sep 17 00:00:00 2001 From: MOshima-PIFSC Date: Fri, 30 Jun 2023 23:41:40 +0000 Subject: [PATCH] style and docs: run devtools::document() and styler::style_pkg() --- tests/testthat.R | 7 ++++--- tests/testthat/SSmase_test.R | 24 ++++++++++++------------ tests/testthat/test-HCxval.R | 4 ++-- tests/testthat/test-plotJABBA.R | 28 ++++++++++++++-------------- tests/testthat/test-runs-test.R | 10 +++++----- tests/testthat/test-uncertainty.R | 2 +- 6 files changed, 38 insertions(+), 37 deletions(-) diff --git a/tests/testthat.R b/tests/testthat.R index 1193a60..f69ff7e 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -13,10 +13,11 @@ r4ss::retro(dir = run_tmp, oldsubdir = "", newsubdir = "retrospectives", years = on.exit(unlink(tmp_path, recursive = TRUE)) # 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", - paste0("retro", 0:-3) - ) + dirvec = file.path( + run_tmp, "retrospectives", + paste0("retro", 0:-3) ) +) retrosum.simple <- r4ss::SSsummarize(retroModels) test_check("ss3diags") diff --git a/tests/testthat/SSmase_test.R b/tests/testthat/SSmase_test.R index e6d0f4d..893b116 100644 --- a/tests/testthat/SSmase_test.R +++ b/tests/testthat/SSmase_test.R @@ -1,31 +1,31 @@ ## File is deprecated by MOshima 6/12/23 -#library(ss3diags) +# library(ss3diags) # Tests # sma = r4ss::SSsummarize(retro.sma) # Check joint MASE for indices -#SSmase(retro.sma) +# SSmase(retro.sma) # select indices -#SSmase(retro.sma, indexselect = c(4)) +# SSmase(retro.sma, indexselect = c(4)) # check for length comps # smaL = ss3diags::SSretroComps(retro.sma) -#SSmase(retro.sma, quants = "len", indexselect = 2:4) +# SSmase(retro.sma, quants = "len", indexselect = 2:4) # check manually -#mase <- SSmase(retro.sma, residuals = T) +# mase <- SSmase(retro.sma, residuals = T) # Joint mase from index 1, 3,4 -#mae <- apply( +# mae <- apply( # mase$Residuals[c("Pred.Res", "Naive.Res")], 2, # function(x) mean(abs(x)) -#) +# ) # MASE -#mae[1] / mae[2] +# mae[1] / mae[2] # compare -#SSmase(retro.sma) +# SSmase(retro.sma) # Check hake # phk= r4ss::SSsummarize(retro.phk) -#SSmase(retro.phk, verbose = T, indexselect = 1) +# SSmase(retro.phk, verbose = T, indexselect = 1) # check for age comps -#phkA <- ss3diags::SSretroComps(retro.phk) -#SSmase(retro.phk, quants = "age") +# phkA <- ss3diags::SSretroComps(retro.phk) +# SSmase(retro.phk, quants = "age") diff --git a/tests/testthat/test-HCxval.R b/tests/testthat/test-HCxval.R index 5769c42..5925be7 100644 --- a/tests/testthat/test-HCxval.R +++ b/tests/testthat/test-HCxval.R @@ -1,7 +1,7 @@ ## Test script for hindcast cross validation and MASE -#retroSimple <- ss3diags::retroSimple -#retrosum.simple <- r4ss::SSsummarize(retroSimple) +# retroSimple <- ss3diags::retroSimple +# retrosum.simple <- r4ss::SSsummarize(retroSimple) path <- file.path(tempdir(), "test_runs") dir.create(path, showWarnings = FALSE) diff --git a/tests/testthat/test-plotJABBA.R b/tests/testthat/test-plotJABBA.R index 8cf0e57..78644f3 100644 --- a/tests/testthat/test-plotJABBA.R +++ b/tests/testthat/test-plotJABBA.R @@ -1,5 +1,5 @@ ## Test script for JABBA residual plot -simple <- r4ss::SS_output(dir = test_example_path, verbose=FALSE, printstats = FALSE) +simple <- r4ss::SS_output(dir = test_example_path, verbose = FALSE, printstats = FALSE) path <- file.path(tempdir(), "test_runs") dir.create(path, showWarnings = FALSE) @@ -30,19 +30,19 @@ test_that("file of simple_len_jabbaresiduals plot exists", { }) ## CAAL uncomment when con option is finished in function -#test_that("file of simple_con_jabbaresiduals plot exists", { - # - #SSplotJABBAres(simple, - #use_png = TRUE, - #print_plot = TRUE, - #subplots = "con", - #plotdir = path, - #filenameprefix = "simple_con_" - #) - - #expect_true(file.exists(file.path(path, "simple_con_jabbaresidual.png"))) - # -#}) +# test_that("file of simple_con_jabbaresiduals plot exists", { +# +# SSplotJABBAres(simple, +# use_png = TRUE, +# print_plot = TRUE, +# subplots = "con", +# plotdir = path, +# filenameprefix = "simple_con_" +# ) + +# expect_true(file.exists(file.path(path, "simple_con_jabbaresidual.png"))) +# +# }) test_that("calculate RMSE for CPUE index", { rmse <- SSrmse(simple, quants = "cpue") diff --git a/tests/testthat/test-runs-test.R b/tests/testthat/test-runs-test.R index 4dc6ddf..094ad92 100644 --- a/tests/testthat/test-runs-test.R +++ b/tests/testthat/test-runs-test.R @@ -1,4 +1,4 @@ -simple <- r4ss::SS_output(dir = test_example_path, verbose=FALSE, printstats = FALSE) +simple <- r4ss::SS_output(dir = test_example_path, verbose = FALSE, printstats = FALSE) #### Simple Model ############################################################### @@ -127,11 +127,11 @@ test_that("runs test works with simple model", { run_cpue <- SSrunstest(simple, quants = "len", indexselect = 2) expect_match(run_cpue$Index, "SURVEY1") - # CAAL since switching to simple_small, there is no conditional-age-at-length data. - #run_con <- SSrunstest(simple, quants = "con") + # CAAL since switching to simple_small, there is no conditional-age-at-length data. + # run_con <- SSrunstest(simple, quants = "con") - #expect_match(run_con$Index, "Fishery") - #expect_match(run_con$test, "Passed") + # expect_match(run_con$Index, "Fishery") + # expect_match(run_con$test, "Passed") }) diff --git a/tests/testthat/test-uncertainty.R b/tests/testthat/test-uncertainty.R index 04359f1..f8670d7 100644 --- a/tests/testthat/test-uncertainty.R +++ b/tests/testthat/test-uncertainty.R @@ -1,5 +1,5 @@ # Test script for evaluating model uncertainty -simple <- r4ss::SS_output(dir = test_example_path, verbose=FALSE, printstats = FALSE) +simple <- r4ss::SS_output(dir = test_example_path, verbose = FALSE, printstats = FALSE) mvln.msy <- SSdeltaMVLN(simple, Fref = "MSY")