Skip to content

Commit fa28224

Browse files
committed
add test for traj_list_to_df() #58
openjournals/joss-reviews#3888
1 parent ba06717 commit fa28224

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/testthat/test-traj_list_to_df.R

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
test_that("check that traj_list_to_df returns the right number of dims", {
2+
parms <- list(
3+
S0 = 0.944, S1plus = 0.99, K1plus = 9000, AgeMat = 18,
4+
nages = 25, z = 2.39, lambdaMax = 1.02
5+
)
6+
nyears <- 50
7+
initdepl.vec <- c(0.2, 0.5, 0.9)
8+
nout <- 50
9+
high.list.const <- lapply(
10+
X = initdepl.vec,
11+
function(x) {
12+
projections(
13+
NOut = nout,
14+
ConstantBycatch = list(Catch = 25, CV = 0.3),
15+
InitDepl = x,
16+
lh.params = parms,
17+
nyears = nyears,
18+
obs_CV = 0.1
19+
)
20+
}
21+
)
22+
med.list.const <- lapply(
23+
X = initdepl.vec,
24+
function(x) {
25+
projections(
26+
NOut = nout,
27+
ConstantBycatch = list(Catch = 12, CV = 0.3),
28+
InitDepl = x,
29+
lh.params = parms,
30+
nyears = nyears,
31+
obs_CV = 0.1
32+
)
33+
}
34+
)
35+
low.list.const <- lapply(
36+
X = initdepl.vec,
37+
function(x) {
38+
projections(
39+
NOut = nout,
40+
ConstantBycatch = list(Catch = 2, CV = 0.3),
41+
InitDepl = x,
42+
lh.params = parms,
43+
nyears = nyears,
44+
obs_CV = 0.1
45+
)
46+
}
47+
)
48+
zero.list.const <- lapply(
49+
X = initdepl.vec,
50+
function(x) {
51+
projections(
52+
NOut = nout,
53+
ConstantBycatch = list(Catch = 0, CV = 0),
54+
InitDepl = x,
55+
lh.params = parms,
56+
nyears = nyears,
57+
obs_CV = 0.1
58+
)
59+
}
60+
)
61+
traj.list <- list(
62+
high.list.const,
63+
med.list.const,
64+
low.list.const,
65+
zero.list.const
66+
)
67+
68+
test_df <- traj_list_to_df(traj.list)
69+
70+
expect_equal(nrow(test_df), length(initdepl.vec) * length(traj.list) * nout)
71+
})

0 commit comments

Comments
 (0)