File: getRequirements.R

package info (click to toggle)
r-cran-paramhelpers 1.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 992 kB
  • sloc: ansic: 102; sh: 13; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#' @title Return all require-expressions of a param set.
#'
#' @description
#' Returns all `require`s-objects of a param set as a list.
#'
#' @template arg_parset
#' @param remove.null (`logical(1)`)\cr
#'   If not set, params without a requires-setting will result in a `NULL`
#'   element in the returned list, otherwise they are removed. Default is
#'   \code{TRUE}.
#' @return xnamed `list`.
#'   Named list of require-call-objects, lengths corresponds to number of params
#'   (potentially only the subset with requires-field), named with with param
#'   ids.
#' @export
getRequirements = function(par.set, remove.null = TRUE) {
  assertClass(par.set, "ParamSet")
  assertFlag(remove.null)
  res = extractSubList(par.set$pars, "requires", simplify = FALSE, use.names = TRUE)
  if (remove.null) {
    res = filterNull(res)
  }
  return(res)
}