Running ‘testthat.R’ [4s/5s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(blockForest)
  > 
  > test_check("blockForest")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  blockForest
   --- call from context --- 
  blockfor(X, ysurv, num.trees = 5, replace = TRUE, blocks = blocks, 
      nsets = 2, num.trees.pre = 3, splitrule = "maxstat", block.method = "BlockForest")
   --- call from argument --- 
  if (class(y) == "matrix") {
      if (ncol(y) == 2) {
          y <- Surv(time = y[, 1], event = y[, 2])
          model.data <- data.frame(y, X)
      }
  } else model.data <- data.frame(y, X)
   --- R stacktrace ---
  where 1 at testthat/test_blockfor.R#29: blockfor(X, ysurv, num.trees = 5, replace = TRUE, blocks = blocks, 
      nsets = 2, num.trees.pre = 3, splitrule = "maxstat", block.method = "BlockForest")
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 12: test_code(desc, code, env = parent.frame())
  where 13 at testthat/test_blockfor.R#23: test_that("Split rule parameter is used in blockForest", {
      blockforobj <- blockfor(X, ybin, num.trees = 5, replace = TRUE, 
          blocks = blocks, nsets = 2, num.trees.pre = 3, block.method = "BlockForest")
      expect_equal(blockforobj$forest$splitrule, "extratrees")
      blockforobj <- blockfor(X, ysurv, num.trees = 5, replace = TRUE, 
          blocks = blocks, nsets = 2, num.trees.pre = 3, splitrule = "maxstat", 
          block.method = "BlockForest")
      expect_equal(blockforobj$forest$splitrule, "maxstat")
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 24: test_code(NULL, exprs, env)
  where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 26: force(code)
  where 27: doWithOneRestart(return(expr), restart)
  where 28: withOneRestart(expr, restarts[[1L]])
  where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 31: FUN(X[[i]], ...)
  where 32: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 33: force(code)
  where 34: doWithOneRestart(return(expr), restart)
  where 35: withOneRestart(expr, restarts[[1L]])
  where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 37: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 40: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: test_check("blockForest")
  
   --- value of length: 2 type: logical ---
  [1]  TRUE FALSE
   --- function from context --- 
  function (X, y, blocks, block.method = "BlockForest", num.trees = 2000, 
      mtry = NULL, nsets = 300, num.trees.pre = 1500, splitrule = "extratrees", 
      always.select.block = 0, ...) 
  {
      if (class(y) == "matrix") {
          if (ncol(y) == 2) {
              y <- Surv(time = y[, 1], event = y[, 2])
              model.data <- data.frame(y, X)
          }
      }
      else model.data <- data.frame(y, X)
      if (class(model.data[, 1]) == "factor") {
          treetype <- "Classification"
      }
      else if (class(model.data[, 1]) == "numeric") {
          treetype <- "Regression"
      }
      else if (class(model.data[, 1]) == "Surv") {
          treetype <- "Survival"
      }
      else {
          stop("Unkown response type.")
      }
      if (missing(blocks)) 
          stop("Argument 'blocks' must be provided.")
      if (is.null(mtry)) {
          if (block.method %in% c("SplitWeights", "VarProb")) 
              mtry <- sum(sqrt(sapply(blocks, length)))
          else mtry <- sapply(blocks, function(x) sqrt(length(x)))
      }
      model.data[, -1] <- sapply(model.data[, -1], as.numeric)
      if (always.select.block > 0 & block.method %in% c("SplitWeights", 
          "RandomBlock")) {
          always.split.variables <- colnames(model.data[, -1])[blocks[[always.select.block]]]
      }
      else {
          always.split.variables <- NULL
      }
      if (always.select.block > 0 & block.method %in% c("BlockVarSel", 
          "BlockForest")) {
          mtry[always.select.block] <- length(blocks[[always.select.block]])
      }
      if (treetype == "Survival") {
          model.data <- data.frame(time = model.data[, 1][, 1], 
              status = model.data[, 1][, 2], model.data[, -1])
      }
      if (treetype == "Classification") {
          cvalueoptim <- CvalueOptimizerClassification$new(nsets = as.integer(nsets), 
              num.trees.pre = as.integer(num.trees.pre), mtry = as.integer(mtry), 
              data = model.data, response_levels = levels(model.data[, 
                  1]), blocks = blocks, block.method = block.method, 
              splitrule = splitrule, always.select.block = as.integer(always.select.block))
          paramvalues <- cvalueoptim$optimizeCvalues(always.split.variables = always.split.variables, 
              ...)
          if (block.method != "VarProb") 
              forest <- blockForest(dependent.variable.name = "y", 
                  data = model.data, num.trees = num.trees, blocks = blocks, 
                  block.weights = paramvalues, mtry = mtry, keep.inbag = TRUE, 
                  block.method = block.method, splitrule = splitrule, 
                  always.split.variables = always.split.variables, 
                  ...)
          else {
              pm <- sapply(blocks, length)
              splitweights <- rep(NA, sum(pm))
              for (blocki in seq(along = blocks)) splitweights[blocks[[blocki]]] <- paramvalues[blocki]
              forest <- blockForest(dependent.variable.name = "y", 
                  data = model.data, num.trees = num.trees, split.select.weights = splitweights, 
                  mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                  splitrule = splitrule, ...)
          }
      }
      else if (treetype == "Regression") {
          cvalueoptim <- CvalueOptimizerRegression$new(nsets = as.integer(nsets), 
              num.trees.pre = as.integer(num.trees.pre), mtry = as.integer(mtry), 
              data = model.data, blocks = blocks, block.method = block.method, 
              splitrule = splitrule, always.select.block = as.integer(always.select.block))
          paramvalues <- cvalueoptim$optimizeCvalues(always.split.variables = always.split.variables, 
              ...)
          if (block.method != "VarProb") 
              forest <- blockForest(dependent.variable.name = "y", 
                  data = model.data, num.trees = num.trees, blocks = blocks, 
                  block.weights = paramvalues, mtry = mtry, keep.inbag = TRUE, 
                  block.method = block.method, splitrule = splitrule, 
                  always.split.variables = always.split.variables, 
                  ...)
          else {
              pm <- sapply(blocks, length)
              splitweights <- rep(NA, sum(pm))
              for (blocki in seq(along = blocks)) splitweights[blocks[[blocki]]] <- paramvalues[blocki]
              forest <- blockForest(dependent.variable.name = "y", 
                  data = model.data, num.trees = num.trees, split.select.weights = splitweights, 
                  mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                  splitrule = splitrule, ...)
          }
      }
      else if (treetype == "Survival") {
          cvalueoptim <- CvalueOptimizerSurvival$new(nsets = as.integer(nsets), 
              num.trees.pre = as.integer(num.trees.pre), mtry = as.integer(mtry), 
              data = model.data, blocks = blocks, block.method = block.method, 
              splitrule = splitrule, always.select.block = as.integer(always.select.block))
          paramvalues <- cvalueoptim$optimizeCvalues(always.split.variables = always.split.variables, 
              ...)
          if (block.method != "VarProb") 
              forest <- blockForest(dependent.variable.name = "time", 
                  status.variable.name = "status", data = model.data, 
                  num.trees = num.trees, blocks = blocks, block.weights = paramvalues, 
                  mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                  splitrule = splitrule, always.split.variables = always.split.variables, 
                  ...)
          else {
              pm <- sapply(blocks, length)
              splitweights <- rep(NA, sum(pm))
              for (blocki in seq(along = blocks)) splitweights[blocks[[blocki]]] <- paramvalues[blocki]
              forest <- blockForest(dependent.variable.name = "time", 
                  status.variable.name = "status", data = model.data, 
                  num.trees = num.trees, split.select.weights = splitweights, 
                  mtry = mtry, keep.inbag = TRUE, block.method = block.method, 
                  splitrule = splitrule, ...)
          }
      }
      else {
          stop("Unkown tree type.")
      }
      res <- list(forest = forest, paramvalues = paramvalues, biased_oob_error_donotuse = forest$prediction.error)
      return(res)
  }
  <bytecode: 0x55fed4277ab0>
  <environment: namespace:blockForest>
   --- function search by body ---
  Function blockfor in namespace blockForest has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1