Skip to content

Commit 05d8658

Browse files
committed
improve regression tests
1 parent 01029c9 commit 05d8658

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/probe_match.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ f1 |> summary() |> names()
5454

5555
f1 |> plot()
5656

57+
pompLoad(f1)
5758
f1 |> probe() |> plot()
59+
pompUnload(f1)
5860

5961
f1 |> as_pomp() |> as.data.frame() |> names()
6062

@@ -69,4 +71,20 @@ po |> probe_objfun(nsim=100,probes=function(x)1,fail.value=1e9) -> f2
6971
logLik(f2)
7072
f2(1)
7173

74+
ricker() |>
75+
probe_objfun(
76+
nsim=1000,
77+
probes=list(
78+
mean=probe_mean("y",trim=0.1,transform=sqrt),
79+
sd=probe_sd("y",transform=sqrt),
80+
probe_quantile("y",prob=c(0.25,0.75),na.rm=TRUE)
81+
),
82+
seed=501991903
83+
) -> f
84+
85+
pompUnload(f)
86+
## f() # would result in segfault
87+
pompLoad(f)
88+
stopifnot(all.equal(round(f(),4),2.7242))
89+
7290
dev.off()

tests/probe_match.Rout.save

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ Error : in 'probe_objfun': parameter 'harry' not found in 'params'.
9090
>
9191
> f1 |> plot()
9292
>
93+
> pompLoad(f1)
9394
> f1 |> probe() |> plot()
95+
> pompUnload(f1)
9496
>
9597
> f1 |> as_pomp() |> as.data.frame() |> names()
9698
[1] "time" "Y"
@@ -110,6 +112,22 @@ Error : in 'probe_objfun': parameter 'harry' not found in 'params'.
110112
> f2(1)
111113
[1] 1e+09
112114
>
115+
> ricker() |>
116+
+ probe_objfun(
117+
+ nsim=1000,
118+
+ probes=list(
119+
+ mean=probe_mean("y",trim=0.1,transform=sqrt),
120+
+ sd=probe_sd("y",transform=sqrt),
121+
+ probe_quantile("y",prob=c(0.25,0.75),na.rm=TRUE)
122+
+ ),
123+
+ seed=501991903
124+
+ ) -> f
125+
>
126+
> pompUnload(f)
127+
> ## f() # would result in segfault
128+
> pompLoad(f)
129+
> stopifnot(all.equal(round(f(),4),2.7242))
130+
>
113131
> dev.off()
114132
null device
115133
1

0 commit comments

Comments
 (0)