Running ‘testthat.R’ [3s/4s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(TDAstats)
  > 
  > test_check("TDAstats")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  TDAstats
   --- call from context --- 
  permutation_test(circle2d, unif2d, iterations = N.ITER, update = 0)
   --- call from argument --- 
  if (class(data1) != "matrix" | class(data2) != "matrix") {
      stop("Both point clouds must be passed as matrices.")
  }
   --- R stacktrace ---
  where 1 at testthat/test_inference.R#12: permutation_test(circle2d, unif2d, iterations = N.ITER, update = 0)
  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_inference.R#4: test_that("Basic permutation test (2-d) works correctly", {
      set.seed(1)
      N.ITER <- 25
      data("circle2d")
      data("unif2d")
      perm.test <- permutation_test(circle2d, unif2d, iterations = N.ITER, 
          update = 0)
      expect_equal(length(perm.test), 2)
      expect_equal(perm.test[[1]]$dimension, 0)
      expect_equal(perm.test[[2]]$dimension, 1)
      expect_equal(length(perm.test[[1]]$permvals), N.ITER)
      expect_equal(length(perm.test[[2]]$permvals), N.ITER)
      expect_true(perm.test[[1]]$pvalue < 0.05)
      perm.test <- permutation_test(unif2d, circle2d, iterations = N.ITER, 
          update = 0)
      expect_equal(length(perm.test), 2)
      expect_equal(perm.test[[1]]$dimension, 0)
      expect_equal(perm.test[[2]]$dimension, 1)
      expect_equal(length(perm.test[[1]]$permvals), N.ITER)
      expect_equal(length(perm.test[[2]]$permvals), N.ITER)
      expect_true(perm.test[[1]]$pvalue < 0.05)
  })
  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("TDAstats")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (data1, data2, iterations, exponent = 1, update = 0, 
      ...) 
  {
      dim <- 1
      list.version <- list(...)
      if (length(list.version) > 0) {
          if (!is.null(list.version$format)) {
              if (list.version$format != "cloud") {
                  stop("Permutation tests only work for point clouds.")
              }
          }
          if (!is.null(list.version$dim)) {
              dim <- as.integer(list.version$dim)
          }
      }
      if (update > 0) {
          cat("Starting function\n")
      }
      if (class(data1) != "matrix" | class(data2) != "matrix") {
          stop("Both point clouds must be passed as matrices.")
      }
      if (update > 0) {
          cat("PASSED error check #1\n")
      }
      if (nrow(data1) < 2 | nrow(data2) < 2) {
          stop("Both point clouds must have at least 2 points (rows) each.")
      }
      if (update > 0) {
          cat("PASSED error check #2\n")
      }
      if (ncol(data1) < 2 | ncol(data2) < 2) {
          stop("Both point clouds must be in least 2 dimensions (columns) each.")
      }
      if (update > 0) {
          cat("PASSED error check #3\n")
      }
      if (ncol(data1) != ncol(data2)) {
          stop("Both point clouds must have the same number of dimensions.")
      }
      if (update > 0) {
          cat("PASSED error check #4\n")
      }
      if (sum(is.na(data1)) > 0 | sum(is.na(data2)) > 0) {
          stop("There should be no NAs in the point clouds passed to this function.")
      }
      if (update > 0) {
          cat("PASSED error check #5\n")
      }
      class.data1 <- class(data1[1, 1])
      class.data2 <- class(data2[1, 1])
      allowed.classes <- c("numeric", "integer")
      if (!(class.data1 %in% allowed.classes) | !(class.data2 %in% 
          allowed.classes)) {
          stop("Point clouds must be formatted as matrices filled with integers or numerics.")
      }
      if (update > 0) {
          cat("PASSED error check #6\n")
      }
      if (iterations <= 1) {
          stop("Permutation test must have at least 2 iterations (preferably more).")
      }
      if (update > 0) {
          cat("PASSED error check #7\n")
      }
      if (update > 0) {
          cat("Beginning calculations\n")
      }
      orig.wass <- wass_cloud_calc(data1, data2, exponent, ...)
      if (update > 0) {
          cat("Initial calculation complete; starting iterations\n")
      }
      combo.pts <- rbind(data1, data2)
      wass.values <- matrix(-1, ncol = ncol(data1), nrow = iterations)
      worked <- vapply(X = 1:iterations, FUN.VALUE = logical(1), 
          FUN = function(curr.iter) {
              if (update > 0 & curr.iter%%update == 0) {
                  cat("At iteration #", curr.iter, "\n", sep = "")
              }
              curr.pts <- combo.pts[sample.int(n = nrow(combo.pts), 
                  size = nrow(combo.pts), replace = FALSE), ]
              curr.wass.calc <- wass_cloud_calc(pts1 = curr.pts[1:nrow(data1), 
                  ], pts2 = curr.pts[(nrow(data1) + 1):nrow(curr.pts), 
                  ], pow.val = exponent, ...)
              wass.values[curr.iter, ] <<- curr.wass.calc[1:ncol(wass.values)]
              return(TRUE)
          })
      answer <- lapply(X = 0:dim, FUN = function(curr.dim) {
          curr.ans <- list()
          curr.ans$dimension <- curr.dim
          curr.ans$permvals <- wass.values[, curr.dim + 1]
          curr.ans$wasserstein <- orig.wass[curr.dim + 1]
          names(curr.ans$wasserstein) <- NULL
          curr.ans$pvalue <- mean(curr.ans$permvals > curr.ans$wasserstein)
          return(curr.ans)
      })
      if (update > 0) {
          cat("Completed calculations\n")
      }
      return(answer)
  }
  <bytecode: 0x5589008ff590>
  <environment: namespace:TDAstats>
   --- function search by body ---
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1