Running ‘testthat.R’ [50s/62s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(SCORPIUS)
  > library(dplyr)
  
  Attaching package: 'dplyr'
  
  The following objects are masked from 'package:stats':
  
      filter, lag
  
  The following objects are masked from 'package:base':
  
      intersect, setdiff, setequal, union
  
  > library(purrr)
  > library(testthat)
  
  Attaching package: 'testthat'
  
  The following object is masked from 'package:purrr':
  
      is_null
  
  The following object is masked from 'package:dplyr':
  
      matches
  
  > 
  > test_check("SCORPIUS")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  SCORPIUS
   --- call from context --- 
  knn(dist, k = 5, self_loops = F)
   --- call from argument --- 
  if (class(dist) == "dist") dist <- as.matrix(dist)
   --- R stacktrace ---
  where 1 at testthat/test-knn.R#12: knn(dist, k = 5, self_loops = F)
  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-knn.R#3: test_that("With generated data", {
      dataset <- generate_dataset(num_genes = 400, num_samples = 101, 
          num_groups = 4)
      expression <- dataset$expression %>% scale_quantile(0)
      time <- seq(-1, 1, length.out = nrow(expression))
      dist <- dynutils::calculate_distance(expression)
      knn_out <- knn(dist, k = 5, self_loops = F)
      expect_equal(rownames(knn_out$indices), rownames(expression))
      expect_equal(rownames(knn_out$distances), rownames(expression))
      expect_equal(ncol(knn_out$indices), 5)
      expect_equal(ncol(knn_out$distances), 5)
      own_dists <- t(sapply(seq_len(nrow(dist)), function(i) dist[i, 
          knn_out$indices[i, ]]))
      expect_true(all(mapply(all.equal, as.vector(knn_out$distances), 
          as.vector(own_dists))))
      expect_true(all(sapply(seq_len(nrow(dist)), function(i) {
          all(setdiff(order(dist[i, ]), i)[1:5] == knn_out$indices[i, 
              ])
      })))
      knn_out <- knn(dist, k = 21, self_loops = F)
      expect_equal(rownames(knn_out$indices), rownames(expression))
      expect_equal(rownames(knn_out$distances), rownames(expression))
      expect_equal(ncol(knn_out$indices), 21)
      expect_equal(ncol(knn_out$distances), 21)
      own_dists <- t(sapply(seq_len(nrow(dist)), function(i) dist[i, 
          knn_out$indices[i, ]]))
      expect_true(all(mapply(all.equal, as.vector(knn_out$distances), 
          as.vector(own_dists))))
      expect_true(all(sapply(seq_len(nrow(dist)), function(i) {
          all(setdiff(order(dist[i, ]), i)[1:21] == knn_out$indices[i, 
              ])
      })))
      knn_out <- knn(dist, k = 5, self_loops = T)
      expect_equal(rownames(knn_out$indices), rownames(expression))
      expect_equal(rownames(knn_out$distances), rownames(expression))
      expect_equal(ncol(knn_out$indices), 5)
      expect_equal(ncol(knn_out$distances), 5)
      own_dists <- t(sapply(seq_len(nrow(dist)), function(i) dist[i, 
          knn_out$indices[i, ]]))
      expect_true(all(mapply(all.equal, as.vector(knn_out$distances), 
          as.vector(own_dists))))
      expect_true(all(sapply(seq_len(nrow(dist)), function(i) {
          all(order(dist[i, ])[1:5] == knn_out$indices[i, ])
      })))
  })
  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("SCORPIUS")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (dist, k, self_loops = FALSE) 
  {
      if (class(dist) == "dist") 
          dist <- as.matrix(dist)
      check_numeric_matrix(dist, "dist", finite = TRUE)
      if (nrow(dist) < 2) 
          stop(sQuote("dist"), " needs to consist of at least 2 rows")
      check_numeric_vector(k, "k", finite = TRUE, whole = TRUE, 
          range = c(1, nrow(dist) - 1), length = 1)
      check_logical_vector(self_loops, "self_loops", length = 1)
      indices <- knndist <- matrix(NA, nrow = nrow(dist), ncol = k, 
          dimnames = list(rownames(dist), if (k == 0) c() else paste0("knn", 
              seq_len(k))))
      row_ix <- if (!is.null(rownames(dist))) 
          rownames(dist)
      else seq_len(nrow(dist))
      col_ix <- if (!is.null(colnames(dist))) 
          colnames(dist)
      else seq_len(ncol(dist))
      if (self_loops) {
          for (i in row_ix) {
              indices[i, ] <- utils::head(order(dist[i, ]), k)
              knndist[i, ] <- dist[i, indices[i, ]]
          }
      }
      else {
          diag(dist) <- 0
          for (i in row_ix) {
              indices[i, ] <- head(order(dist[i, ]), k + 1)[-1]
              knndist[i, ] <- dist[i, indices[i, ]]
          }
      }
      list(indices = indices, distances = knndist)
  }
  <bytecode: 0x56266d8c61b0>
  <environment: namespace:SCORPIUS>
   --- function search by body ---
  Function knn in namespace SCORPIUS has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1