Running 'testthat.R' [4s/5s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library("testthat")
  > library("FastImputation")
  > 
  > test_check("FastImputation")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  FastImputation
   --- call from context --- 
  TrainFastImputation(x = bad_array)
   --- call from argument --- 
  if ("data.frame" != class(x)) stop("Training data must be in a data.frame")
   --- R stacktrace ---
  where 1: TrainFastImputation(x = bad_array)
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      cnd <- cnd_entrace(cnd)
      return_from(env, cnd)
  })
  where 4: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)), 
      ...)
  where 5: quasi_capture(enquo(object), label, capture_error, entrace = TRUE)
  where 6 at testthat/test_TrainFastImputation.R#30: expect_error(TrainFastImputation(x = bad_array), "Training data must be in a data.frame")
  where 7: eval(code, test_env)
  where 8: eval(code, test_env)
  where 9: 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 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 12: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 15: tryCatchList(expr, classes, parentenv, handlers)
  where 16: 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 17: test_code(desc, code, env = parent.frame())
  where 18 at testthat/test_TrainFastImputation.R#29: test_that("TrainFastImputation catches bad input", {
      expect_error(TrainFastImputation(x = bad_array), "Training data must be in a data.frame")
      expect_error(TrainFastImputation(x = good_df, constraints = bad_constraints_upper), 
          "Column 4 does not respect the upper bound specified.")
      expect_error(TrainFastImputation(x = good_df, constraints = bad_constraints_lower), 
          "Column 7 does not respect the lower bound specified.")
      expect_error(TrainFastImputation(x = good_df, constraints = bad_constraints_order), 
          "Column 5 does not respect the lower bound specified.")
      expect_error(TrainFastImputation(x = warning_df, categorical = good_categorical_2), 
          "Too few continuous variables.")
  })
  where 19: eval(code, test_env)
  where 20: eval(code, test_env)
  where 21: 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 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 24: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 27: tryCatchList(expr, classes, parentenv, handlers)
  where 28: 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 29: test_code(NULL, exprs, env)
  where 30: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 31: force(code)
  where 32: doWithOneRestart(return(expr), restart)
  where 33: withOneRestart(expr, restarts[[1L]])
  where 34: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 35: 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 36: FUN(X[[i]], ...)
  where 37: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 38: force(code)
  where 39: doWithOneRestart(return(expr), restart)
  where 40: withOneRestart(expr, restarts[[1L]])
  where 41: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 42: 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 43: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 44: 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 45: 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 46: test_check("FastImputation")
  
   --- value of length: 2 type: logical ---
  [1] TRUE TRUE
   --- function from context --- 
  function (x, constraints = list(), idvars, categorical) 
  {
      if ("data.frame" != class(x)) 
          stop("Training data must be in a data.frame")
      x <- UnfactorColumns(x)
      if (missing(categorical)) {
          cols_categorical <- numeric(0)
      }
      else {
          if (is.numeric(categorical)) {
              cols_categorical <- sort(categorical)
              if (any(cols_categorical > ncol(x))) 
                  stop("Categorical column specified by index that doesn't exist.")
          }
          else {
              cols_categorical <- as.vector(sort(sapply(categorical, 
                  function(col_name) {
                    col_i <- which(names(x) == col_name)
                    if (0 == length(col_i)) 
                      stop("Categorical column specified by name that doesn't exist.")
                    return(col_i)
                  })))
          }
      }
      if (0 == length(constraints)) {
          filled_constraints_in_x <- replicate(ncol(x), list())
      }
      else {
          filled_constraints_in_x <- sapply(1:ncol(x), function(i_col) {
              is_each_constraint_for_this_col <- sapply(constraints, 
                  function(this_cons) {
                    return(this_cons[[1]] == i_col | any((names(x) == 
                      this_cons[[1]]) == i_col))
                  })
              if (0 == sum(is_each_constraint_for_this_col)) {
                  return(list())
              }
              else if (1 == sum(is_each_constraint_for_this_col)) {
                  return(constraints[[which(is_each_constraint_for_this_col)]][[2]])
              }
              else {
                  warning("More than one constraint specified for variable ", 
                    i_col)
                  return(constraints[[max(which(is_each_constraint_for_this_col))]][[2]])
              }
          })
      }
      if (missing(idvars)) {
          cols_to_ignore <- numeric(0)
          y <- x
          filled_constraints_in_y <- filled_constraints_in_x
      }
      else {
          if (is.numeric(idvars)) {
              cols_to_ignore <- idvars
          }
          else {
              cols_to_ignore <- as.vector(sort(sapply(idvars, function(col_name) which(names(x) == 
                  col_name))))
          }
          y <- x[, -cols_to_ignore]
          filled_constraints_in_y <- filled_constraints_in_x[-cols_to_ignore]
          if (length(cols_categorical) > 0) {
              for (cti in rev(sort(cols_to_ignore))) {
                  cols_categorical[cols_categorical > cti] <- cols_categorical[cols_categorical > 
                    cti] - 1
              }
          }
      }
      cols_in_y_bound_to_intervals <- which(sapply(filled_constraints_in_y, 
          function(this_cons) !(is.null(this_cons$upper) && is.null(this_cons$lower))))
      for (i in cols_in_y_bound_to_intervals) {
          if (!is.null(filled_constraints_in_y[[i]]$lower)) {
              if (any(y[, i] < filled_constraints_in_y[[i]]$lower, 
                  na.rm = TRUE)) {
                  stop("Column ", i, " does not respect the lower bound specified.")
              }
          }
          if (!is.null(filled_constraints_in_y[[i]]$upper)) {
              if (any(y[, i] > filled_constraints_in_y[[i]]$upper, 
                  na.rm = TRUE)) {
                  stop("Column ", i, " does not respect the upper bound specified.")
              }
          }
      }
      for (this_col in cols_in_y_bound_to_intervals) {
          y[, this_col] <- NormalizeBoundedVariable(y[, this_col], 
              constraints = filled_constraints_in_y[[this_col]])
      }
      if (length(cols_categorical) > 0) {
          categories <- lapply(cols_categorical, function(i) {
              u <- unique(y[, i])
              return(u[!is.na(u)])
          })
          total_one_hot_dummies <- sum(sapply(categories, length))
          total_not_categorical <- ncol(y) - length(cols_categorical)
          if (total_not_categorical < 2) 
              stop("Too few continuous variables.")
          if (total_one_hot_dummies > total_not_categorical) 
              warning("More categories in categorical variables than continuous variables. Performance will suffer.")
          y_categorical <- y[, cols_categorical, drop = FALSE]
          z <- y[, -cols_categorical]
          z <- data.frame(z, matrix(NA_real_, nrow = nrow(z), ncol = total_one_hot_dummies))
          current_col_to_fill <- 1
          while (current_col_to_fill < total_one_hot_dummies) {
              for (i in 1:length(categories)) {
                  for (j in 1:length(categories[[i]])) {
                    z[, total_not_categorical + current_col_to_fill] <- ifelse(y_categorical[, 
                      i] == categories[[i]][j], 1, -1)
                    current_col_to_fill <- current_col_to_fill + 
                      1
                  }
              }
          }
      }
      else {
          categories <- list()
          z <- y
      }
      FastImputationMeans <- colMeans(z, na.rm = TRUE)
      FastImputationCovariance <- CovarianceWithMissing(z)
      min_size_eigenvalue <- 0.01
      eg <- eigen(FastImputationCovariance)$values
      if (min(eg) < min_size_eigenvalue) {
          eps_ev <- min_size_eigenvalue/abs(eg[1])
          FastImputationCovariance <- Matrix::nearPD(FastImputationCovariance, 
              do2eigen = TRUE, posd.tol = eps_ev)$mat
      }
      patterns <- list(FI_var_names = names(x), FI_means = FastImputationMeans, 
          FI_covariance = FastImputationCovariance, FI_constraints = filled_constraints_in_y, 
          FI_cols_to_ignore = cols_to_ignore, FI_cols_bound_to_intervals = cols_in_y_bound_to_intervals, 
          FI_cols_categorical = cols_categorical, FI_categories = categories)
      class(patterns) <- "FastImputationPatterns"
      return(patterns)
  }
  <bytecode: 0x2e7cd40>
  <environment: namespace:FastImputation>
   --- function search by body ---
  Function TrainFastImputation in namespace FastImputation has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1