Running ‘testthat.R’ [32s/47s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(KernelKnn)
  > 
  > test_check("KernelKnn")
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |=======================                                               |  33%
    |                                                                            
    |===============================================                       |  67%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.02217793 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |=======================                                               |  33%
    |                                                                            
    |===============================================                       |  67%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.1788201 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.0616889 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.04897428 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.0611577 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.04091668 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.06509161 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.03399515 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.06154203 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |==============                                                        |  20%
    |                                                                            
    |============================                                          |  40%
    |                                                                            
    |==========================================                            |  60%
    |                                                                            
    |========================================================              |  80%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.05003381 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |=======================                                               |  33%
    |                                                                            
    |===============================================                       |  67%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.05138564 secs 
  
  
  cross-validation starts .. 
  
    |                                                                            
    |                                                                      |   0%
  
    |                                                                            
    |=======================                                               |  33%
    |                                                                            
    |===============================================                       |  67%
    |                                                                            
    |======================================================================| 100%
  
  time to complete : 0.1888299 secs 
  
  ── 1. Error: the output of the FUN_kernels is the multiplication of a distance m
  the sublist objects must be either matrices or data frames
  Backtrace:
   1. base::lapply(...)
   2. KernelKnn:::FUN(X[[i]], ...)
   3. KernelKnn:::FUN_kernels(x, W, 1)
   4. KernelKnn:::switch.ops(lap, MODE = s_op)
  
  ── 2. Error: adding 3 matrices or data.frames of all 1's results in a a matrix o
  the sublist objects must be either matrices or data frames
  Backtrace:
   1. testthat::expect_equal(...)
   4. KernelKnn:::switch.ops(lst, MODE = "ADD")
  
  ── 3. Error: multiplying 3 matrices or data.frames of all 2's results in a a mat
  the sublist objects must be either matrices or data frames
  Backtrace:
   1. testthat::expect_equal(...)
   4. KernelKnn:::switch.ops(lst, MODE = "MULT")
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  KernelKnn
   --- call from context --- 
  switch.ops(m1, MODE = "MULT")
   --- call from argument --- 
  if (class(LST) != "list") stop("LST must be a list")
   --- R stacktrace ---
  where 1: switch.ops(m1, MODE = "MULT")
  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-utils.R#193: testthat::expect_error(switch.ops(m1, MODE = "MULT"))
  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-utils.R#190: testthat::test_that("if LST is not a list it throws error", {
      m1 = matrix(rep(1, 25), 5, 5)
      testthat::expect_error(switch.ops(m1, MODE = "MULT"))
  })
  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("KernelKnn")
  
   --- value of length: 2 type: logical ---
  [1] TRUE TRUE
   --- function from context --- 
  function (LST, MODE = "ADD") 
  {
      if (class(LST) != "list") 
          stop("LST must be a list")
      if (!all(unlist(lapply(LST, class)) %in% c("data.frame", 
          "matrix"))) 
          stop("the sublist objects must be either matrices or data frames")
      r = all(unlist(lapply(LST, nrow)) == unlist(lapply(LST, nrow))[1])
      c = all(unlist(lapply(LST, ncol)) == unlist(lapply(LST, ncol))[1])
      if (!all(c(r, c))) 
          stop("the dimensions of the included data.frames or matrices differ")
      if (MODE == "ADD") {
          init_df = data.frame(matrix(rep(0, dim(LST[[1]])[1] * 
              dim(LST[[1]])[2]), nrow = dim(LST[[1]])[1], ncol = dim(LST[[1]])[2]))
      }
      else if (MODE == "MULT") {
          init_df = data.frame(matrix(rep(1, dim(LST[[1]])[1] * 
              dim(LST[[1]])[2]), nrow = dim(LST[[1]])[1], ncol = dim(LST[[1]])[2]))
      }
      else {
          stop("invalid MODE type")
      }
      for (i in 1:length(LST)) {
          if (MODE == "ADD") {
              init_df = init_df + LST[[i]]
          }
          if (MODE == "MULT") {
              init_df = init_df * LST[[i]]
          }
      }
      colnames(init_df) = colnames(LST[[1]])
      return(as.matrix(init_df))
  }
  <bytecode: 0x55f2187abd40>
  <environment: namespace:KernelKnn>
   --- function search by body ---
  Function switch.ops in namespace KernelKnn has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1