Skip to content

Commit

Permalink
improve regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kingaa committed Mar 20, 2023
1 parent 01029c9 commit 05d8658
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/probe_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ f1 |> summary() |> names()

f1 |> plot()

pompLoad(f1)
f1 |> probe() |> plot()
pompUnload(f1)

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

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

ricker() |>
probe_objfun(
nsim=1000,
probes=list(
mean=probe_mean("y",trim=0.1,transform=sqrt),
sd=probe_sd("y",transform=sqrt),
probe_quantile("y",prob=c(0.25,0.75),na.rm=TRUE)
),
seed=501991903
) -> f

pompUnload(f)
## f() # would result in segfault
pompLoad(f)
stopifnot(all.equal(round(f(),4),2.7242))

dev.off()
18 changes: 18 additions & 0 deletions tests/probe_match.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ Error : in 'probe_objfun': parameter 'harry' not found in 'params'.
>
> f1 |> plot()
>
> pompLoad(f1)
> f1 |> probe() |> plot()
> pompUnload(f1)
>
> f1 |> as_pomp() |> as.data.frame() |> names()
[1] "time" "Y"
Expand All @@ -110,6 +112,22 @@ Error : in 'probe_objfun': parameter 'harry' not found in 'params'.
> f2(1)
[1] 1e+09
>
> ricker() |>
+ probe_objfun(
+ nsim=1000,
+ probes=list(
+ mean=probe_mean("y",trim=0.1,transform=sqrt),
+ sd=probe_sd("y",transform=sqrt),
+ probe_quantile("y",prob=c(0.25,0.75),na.rm=TRUE)
+ ),
+ seed=501991903
+ ) -> f
>
> pompUnload(f)
> ## f() # would result in segfault
> pompLoad(f)
> stopifnot(all.equal(round(f(),4),2.7242))
>
> dev.off()
null device
1
Expand Down

0 comments on commit 05d8658

Please sign in to comment.