R/addons-rugarch.R

Defines functions append_transpilers_for_rugarch

# rugarch::arfimacv(..., cluster = cl) =>
#
# local({
#   cl <- future::makeClusterFuture(<future arguments>)
#   on.exit(options(oopts))
#   rugarch::arfimacv(..., cluster = cl)
# })
#
append_transpilers_for_rugarch <- function() {
  if (getRversion() < "4.4.0") {
    stop(sprintf("You are running R %s, but futurization of 'rugarch' functions requires R (>= 4.4.0)", getRversion()))
  }

  transpilers <- make_package_transpilers("rugarch", FUN = function(fcn, name) {
    if ("cluster" %in% names(formals(fcn))) {
      transpiler <- make_futurize_for_makeClusterFuture(
        args = list(
          cluster = quote(cl)
        ),
        defaults = list(
          label = sprintf("fz:rugarch::%s", name),
          seed = TRUE
        )
      )
      
      list(
        label = sprintf("rugarch::%s() ~> rugarch::%s(..., cluster = cl)", name, name),
        transpiler = transpiler
      )
    }
  })

  append_transpilers("futurize::add-on", transpilers)

  ## Return required packages
  c("rugarch", "future")
}

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.