inst/testme/test-futurize-Sim.DiffProc.R

#' @tags pkg-Sim.DiffProc
if (requireNamespace("Sim.DiffProc") && getRversion() >= "4.4.0") {
library(futurize)
library(Sim.DiffProc)
fcns <- tryCatch({
  futurize::futurize_supported_functions("Sim.DiffProc")
}, error = identity)
print(fcns)
stopifnot(is.character(fcns), length(fcns) > 0L)
options(future.rng.onMisuse = "error")

plan(multisession)

#------------------------------------------------------------------
# MCM.sde()
#------------------------------------------------------------------
message("MCM.sde() ...")

f <- expression(0)
g <- expression(1)
mod1d <- snssde1d(drift=f, diffusion=g, x0=1, M=10, N=100)
stat <- function(x, ...) mean(x)

res_truth <- MCM.sde(mod1d, statistic = stat, R = 10, time = 0.5)

res <- MCM.sde(mod1d, statistic = stat, R = 10, time = 0.5) |> futurize_and_verify()

## Compare structure/metadata since simulation results themselves are stochastic
stopifnot(
  identical(class(res), class(res_truth)),
  identical(names(res), names(res_truth)),
  identical(res$dim, res_truth$dim),
  identical(res$Class, res_truth$Class)
)

message("MCM.sde() ... done")

plan(sequential)
}

Try the futurize package in your browser

Any scripts or data that you put into this service are public.

futurize documentation built on Oct. 20, 2026, 1:06 a.m.