Skip to content

Commit

Permalink
style and docs: run devtools::document() and styler::style_pkg()
Browse files Browse the repository at this point in the history
  • Loading branch information
MOshima-PIFSC authored and github-actions[bot] committed Jun 30, 2023
1 parent c7c236e commit a5ee9f9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
7 changes: 4 additions & 3 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
24 changes: 12 additions & 12 deletions tests/testthat/SSmase_test.R
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 2 additions & 2 deletions tests/testthat/test-HCxval.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
28 changes: 14 additions & 14 deletions tests/testthat/test-plotJABBA.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-runs-test.R
Original file line number Diff line number Diff line change
@@ -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 ###############################################################

Expand Down Expand Up @@ -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")
})


Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-uncertainty.R
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit a5ee9f9

Please sign in to comment.