Running ‘testthat.R’ [9s/14s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(ssc)
  > 
  > test_check("ssc")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  ssc
   --- call from context --- 
  setredG(y, x, gen.learner1, gen.pred1, theta, max.iter, perc.full)
   --- call from argument --- 
  if (class(D) == "dist") {
      D <- proxy::as.matrix(D)
  }
   --- R stacktrace ---
  where 1: setredG(y, x, gen.learner1, gen.pred1, theta, max.iter, perc.full)
  where 2 at testthat/test_SETRED.R#16: setred(x = wine$dtrain, y = wine$ytrain, x.inst = FALSE, learner = knn3)
  where 3: eval(code, test_env)
  where 4: eval(code, test_env)
  where 5: 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 6: doTryCatch(return(expr), name, parentenv, handler)
  where 7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 8: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 9: doTryCatch(return(expr), name, parentenv, handler)
  where 10: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 11: tryCatchList(expr, classes, parentenv, handlers)
  where 12: 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 13: test_code(desc, code, env = parent.frame())
  where 14 at testthat/test_SETRED.R#6: test_that(desc = "setred works", code = {
      m <- setred(x = wine$xtrain, y = wine$ytrain, learner = knn3)
      expect_is(m, "setred")
      p <- predict(m, wine$xitest)
      expect_is(p, "factor")
      expect_equal(length(p), length(wine$ytrain))
      m <- setred(x = wine$dtrain, y = wine$ytrain, x.inst = FALSE, 
          learner = knn3)
      expect_is(m, "setred")
      p <- predict(m, wine$ditest[, m$instances.index])
      expect_is(p, "factor")
      expect_equal(length(p), length(wine$ytrain))
  })
  where 15: eval(code, test_env)
  where 16: eval(code, test_env)
  where 17: 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 18: doTryCatch(return(expr), name, parentenv, handler)
  where 19: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 20: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 21: doTryCatch(return(expr), name, parentenv, handler)
  where 22: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 23: tryCatchList(expr, classes, parentenv, handlers)
  where 24: 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 25: test_code(NULL, exprs, env)
  where 26: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 27: force(code)
  where 28: doWithOneRestart(return(expr), restart)
  where 29: withOneRestart(expr, restarts[[1L]])
  where 30: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 31: 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 32: FUN(X[[i]], ...)
  where 33: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: 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 39: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 40: 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 41: 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 42: test_check("ssc")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (y, D, gen.learner, gen.pred, theta = 0.1, max.iter = 50, 
      perc.full = 0.7) 
  {
      if (!is.factor(y)) {
          if (!is.vector(y)) {
              stop("Parameter y is neither a vector nor a factor.")
          }
          else {
              y = as.factor(y)
          }
      }
      if (class(D) == "dist") {
          D <- proxy::as.matrix(D)
      }
      if (!is.matrix(D)) {
          stop("Parameter D is neither a matrix or a dist object.")
      }
      else if (nrow(D) != ncol(D)) {
          stop("The distance matrix D is not a square matrix.")
      }
      else if (nrow(D) != length(y)) {
          stop(sprintf(paste("The dimensions of the matrix D is %i x %i", 
              "and it's expected %i x %i according to the size of y."), 
              nrow(D), ncol(D), length(y), length(y)))
      }
      if (!(theta >= 0 && theta <= 1)) {
          stop("theta must be between 0 and 1")
      }
      if (max.iter < 1) {
          stop("Parameter max.iter is less than 1. Expected a value greater than and equal to 1.")
      }
      if (perc.full < 0 || perc.full > 1) {
          stop("Parameter perc.full is not in the range 0 to 1.")
      }
      classes <- levels(y)
      nclasses <- length(classes)
      ynew <- y
      labeled <- which(!is.na(y))
      unlabeled <- which(is.na(y))
      if (length(labeled) == 0) {
          stop("The labeled set is empty. All the values in y parameter are NA.")
      }
      if (length(unlabeled) == 0) {
          stop("The unlabeled set is empty. None value in y parameter is NA.")
      }
      cls.summary <- summary(y[labeled])
      proportion <- cls.summary/length(labeled)
      cantClass <- round(cls.summary/min(cls.summary))
      totalPerIter <- sum(cantClass)
      count.full <- length(labeled) + round(length(unlabeled) * 
          perc.full)
      iter <- 1
      while ((length(labeled) < count.full) && (length(unlabeled) >= 
          totalPerIter) && (iter <= max.iter)) {
          model <- gen.learner(labeled, ynew[labeled])
          prob <- checkProb(prob = gen.pred(model, unlabeled), 
              ninstances = length(unlabeled), classes)
          selection <- selectInstances(cantClass, prob)
          nlabeled.old <- length(labeled)
          labeled.prime <- unlabeled[selection$unlabeled.idx]
          sel.classes <- classes[selection$class.idx]
          ynew[labeled.prime] <- sel.classes
          labeled <- c(labeled, labeled.prime)
          unlabeled <- unlabeled[-selection$unlabeled.idx]
          nlabeled.new <- length(labeled)
          ady <- vector("list", nlabeled.new)
          for (i in (nlabeled.old + 1):nlabeled.new) {
              for (j in 1:(i - 1)) {
                  con <- TRUE
                  for (k in 1:nlabeled.new) if (k != i && k != 
                    j && D[labeled[i], labeled[j]] > max(D[labeled[i], 
                    labeled[k]], D[labeled[k], labeled[j]])) {
                    con <- FALSE
                    break
                  }
                  if (con) {
                    ady[[i]] <- c(ady[[i]], j)
                    ady[[j]] <- c(ady[[j]], i)
                  }
              }
          }
          noise.insts <- c()
          for (i in (nlabeled.old + 1):nlabeled.new) {
              propi <- proportion[unclass(ynew[labeled[i]])]
              Oi <- 0
              nv <- W <- k <- 0
              for (j in ady[[i]]) {
                  k <- k + 1
                  W[k] <- 1/(1 + D[labeled[i], labeled[j]])
                  if (ynew[labeled[i]] != ynew[labeled[j]]) {
                    Oi <- Oi + W[k]
                    nv <- nv + 1
                  }
              }
              if (normalCriterion(theta, Oi, length(ady[[i]]), 
                  propi, W)) {
                  noise.insts <- c(noise.insts, i)
              }
          }
          if (length(noise.insts) > 0) {
              ynew[labeled[noise.insts]] <- NA
              labeled <- labeled[-noise.insts]
          }
          iter <- iter + 1
      }
      model <- gen.learner(labeled, ynew[labeled])
      result <- list(model = model, instances.index = labeled)
      class(result) <- "setredG"
      result
  }
  <bytecode: 0x5588136b1238>
  <environment: namespace:ssc>
   --- function search by body ---
  Function setredG in namespace ssc has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1