Running 'testthat.R' [4s/4s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(SeqNet)
  > 
  > test_check("SeqNet")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  SeqNet
   --- call from context --- 
  rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
   --- call from argument --- 
  if (!(class(x) == "matrix")) stop(paste0("'", deparse(substitute(x)), 
      "' is not a 'matrix' object."))
   --- R stacktrace ---
  where 1: rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
  where 2: rewire_connections_to_node(adj, i, prob_rewire, weights, alpha, 
      beta, epsilon, run_checks = FALSE, ...)
  where 3 at testthat/test_create_network.R#2: random_module_structure(10)
  where 4: eval(code, test_env)
  where 5: eval(code, test_env)
  where 6: 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 7: doTryCatch(return(expr), name, parentenv, handler)
  where 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 9: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 12: tryCatchList(expr, classes, parentenv, handlers)
  where 13: 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 14: test_code(desc, code, env = parent.frame())
  where 15 at testthat/test_create_network.R#1: testthat::test_that("networks can be created from matricies", 
      {
          adj <- random_module_structure(10)
          colnames(adj) <- 1:10
          expect_is(adj, "matrix")
          expect_true(is_adjacency_cpp(adj))
          network <- create_network_from_adjacency_matrix(adj)
          expect_is(network, "network")
          expect_equal(get_adjacency_matrix(network), adj)
          network <- gen_partial_correlations(network)
          assoc <- get_association_matrix(network)
          expect_is(assoc, "matrix")
          network <- create_network_from_association_matrix(assoc)
          expect_is(network, "network")
          expect_equal(get_association_matrix(network), assoc)
          expect_equal(get_adjacency_matrix(network), get_adjacency_matrix(assoc))
      })
  where 16: eval(code, test_env)
  where 17: eval(code, test_env)
  where 18: 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 19: doTryCatch(return(expr), name, parentenv, handler)
  where 20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 21: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 24: tryCatchList(expr, classes, parentenv, handlers)
  where 25: 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 26: test_code(NULL, exprs, env)
  where 27: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: 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 33: FUN(X[[i]], ...)
  where 34: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 35: force(code)
  where 36: doWithOneRestart(return(expr), restart)
  where 37: withOneRestart(expr, restarts[[1L]])
  where 38: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 39: 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 40: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: 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 42: 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 43: test_check("SeqNet")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (x, node, prob_rewire = 1, weights = NULL, alpha = 100, 
      beta = 1, epsilon = 10^-5, run_checks = TRUE, ...) 
  {
      if (!(class(x) == "matrix")) 
          stop(paste0("'", deparse(substitute(x)), "' is not a 'matrix' object."))
      if (run_checks && is_weighted(x)) {
          warning("'", deparse(substitute(x)), "' is weighted.", 
              "Edge weights are removed prior to rewiring.")
          x <- remove_weights(x)
      }
      if (run_checks && !is_adjacency_cpp(x)) {
          stop("'", deparse(substitute(x)), "' is not an adjacency matrix.")
      }
      nodes <- get_node_names(x)
      p <- length(nodes)
      if (node <= 0) 
          stop("Argument 'node' must be a positive integer.")
      if (prob_rewire < 0 || prob_rewire > 1) 
          stop("Argument 'prob_rewire' must be in [0, 1].")
      if (!is.null(weights) && (length(weights) != p || !is.numeric(weights))) 
          stop("'", deparse(substitute(weights)), "' is not a numeric vector of length", 
              " equal to the number of nodes in m.")
      if (is.null(weights)) {
          weights <- rep(0, p)
      }
      if (node %in% nodes) {
          node_index <- which(node == nodes)
          degree <- colSums(x)
          weights <- weights + degree
          if (degree[node_index] > 0 && degree[node_index] != (p - 
              1)) {
              neighbors <- which(x[, node_index] != 0)
              available <- (1:p)[-c(node_index, neighbors)]
              n_rewire <- sum(runif(length(neighbors)) < prob_rewire)
              if (n_rewire > 0) {
                  if (length(neighbors) == 1) {
                    neighbors <- neighbors
                  }
                  else {
                    neighbors <- sample(neighbors, n_rewire)
                  }
                  for (old_neighbor in neighbors) {
                    if (length(available) == 1) {
                      new_neighbor <- available
                    }
                    else {
                      new_neighbor <- sample(available, 1, prob = pbeta(ecdf_cpp(weights[available]), 
                        alpha, beta) + epsilon)
                    }
                    x[old_neighbor, node_index] <- 0
                    x[node_index, old_neighbor] <- 0
                    x[new_neighbor, node_index] <- 1
                    x[node_index, new_neighbor] <- 1
                    available[which(available == new_neighbor)] <- old_neighbor
                    weights[new_neighbor] <- weights[new_neighbor] + 
                      1
                    weights[old_neighbor] <- weights[old_neighbor] - 
                      1
                  }
              }
          }
      }
      else {
          warning("'", deparse(substitute(node)), "' is not a node in 'x'.", 
              "Returning 'x' unmodified.")
      }
      return(x)
  }
  <bytecode: 0x2b11648>
  <environment: namespace:SeqNet>
   --- function search by body ---
  Function rewire_connections_to_node.matrix in namespace SeqNet has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Error: networks can be created from matricies (@test_create_network.R#2)  
  the condition has length > 1
  Backtrace:
   1. SeqNet::random_module_structure(10)
   3. SeqNet:::rewire_connections_to_node.matrix(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  SeqNet
   --- call from context --- 
  rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
   --- call from argument --- 
  if (!(class(x) == "matrix")) stop(paste0("'", deparse(substitute(x)), 
      "' is not a 'matrix' object."))
   --- R stacktrace ---
  where 1: rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
  where 2: rewire_connections_to_node(adj, i, prob_rewire, weights, alpha, 
      beta, epsilon, run_checks = FALSE, ...)
  where 3: random_module_structure(length(nodes), ...)
  where 4: random_module(nodes, weights = deg[nodes], ...)
  where 5: create_modules_for_network(n_modules, p, ...)
  where 6: random_network(20)
  where 7: get_network_arguments(...)
  where 8: gen_partial_correlations(random_network(20))
  where 9 at testthat/test_gen_counts.R#5: gen_rnaseq(10, gen_partial_correlations(random_network(20)), 
      reference)
  where 10: eval(code, test_env)
  where 11: eval(code, test_env)
  where 12: 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 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 15: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 16: doTryCatch(return(expr), name, parentenv, handler)
  where 17: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 18: tryCatchList(expr, classes, parentenv, handlers)
  where 19: 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 20: test_code(desc, code, env = parent.frame())
  where 21 at testthat/test_gen_counts.R#1: testthat::test_that("counts can be generated", {
      reference <- matrix(rpois(200, 10), nrow = 10, ncol = 20)
      x <- gen_rnaseq(10, gen_partial_correlations(create_empty_network(20)), 
          reference)$x
      expect_is(x, "matrix")
      x <- gen_rnaseq(10, gen_partial_correlations(random_network(20)), 
          reference)$x
      expect_is(x, "matrix")
      x <- gen_rnaseq(20, gen_partial_correlations(random_network(20)), 
          reference)$x
      expect_is(x, "matrix")
      x <- gen_rnaseq(20, gen_partial_correlations(random_network(10)), 
          reference)$x
      expect_is(x, "matrix")
  })
  where 22: eval(code, test_env)
  where 23: eval(code, test_env)
  where 24: 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 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 27: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 28: doTryCatch(return(expr), name, parentenv, handler)
  where 29: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 30: tryCatchList(expr, classes, parentenv, handlers)
  where 31: 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 32: test_code(NULL, exprs, env)
  where 33: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 39: FUN(X[[i]], ...)
  where 40: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 41: force(code)
  where 42: doWithOneRestart(return(expr), restart)
  where 43: withOneRestart(expr, restarts[[1L]])
  where 44: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 45: 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 46: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 47: 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 48: 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 49: test_check("SeqNet")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (x, node, prob_rewire = 1, weights = NULL, alpha = 100, 
      beta = 1, epsilon = 10^-5, run_checks = TRUE, ...) 
  {
      if (!(class(x) == "matrix")) 
          stop(paste0("'", deparse(substitute(x)), "' is not a 'matrix' object."))
      if (run_checks && is_weighted(x)) {
          warning("'", deparse(substitute(x)), "' is weighted.", 
              "Edge weights are removed prior to rewiring.")
          x <- remove_weights(x)
      }
      if (run_checks && !is_adjacency_cpp(x)) {
          stop("'", deparse(substitute(x)), "' is not an adjacency matrix.")
      }
      nodes <- get_node_names(x)
      p <- length(nodes)
      if (node <= 0) 
          stop("Argument 'node' must be a positive integer.")
      if (prob_rewire < 0 || prob_rewire > 1) 
          stop("Argument 'prob_rewire' must be in [0, 1].")
      if (!is.null(weights) && (length(weights) != p || !is.numeric(weights))) 
          stop("'", deparse(substitute(weights)), "' is not a numeric vector of length", 
              " equal to the number of nodes in m.")
      if (is.null(weights)) {
          weights <- rep(0, p)
      }
      if (node %in% nodes) {
          node_index <- which(node == nodes)
          degree <- colSums(x)
          weights <- weights + degree
          if (degree[node_index] > 0 && degree[node_index] != (p - 
              1)) {
              neighbors <- which(x[, node_index] != 0)
              available <- (1:p)[-c(node_index, neighbors)]
              n_rewire <- sum(runif(length(neighbors)) < prob_rewire)
              if (n_rewire > 0) {
                  if (length(neighbors) == 1) {
                    neighbors <- neighbors
                  }
                  else {
                    neighbors <- sample(neighbors, n_rewire)
                  }
                  for (old_neighbor in neighbors) {
                    if (length(available) == 1) {
                      new_neighbor <- available
                    }
                    else {
                      new_neighbor <- sample(available, 1, prob = pbeta(ecdf_cpp(weights[available]), 
                        alpha, beta) + epsilon)
                    }
                    x[old_neighbor, node_index] <- 0
                    x[node_index, old_neighbor] <- 0
                    x[new_neighbor, node_index] <- 1
                    x[node_index, new_neighbor] <- 1
                    available[which(available == new_neighbor)] <- old_neighbor
                    weights[new_neighbor] <- weights[new_neighbor] + 
                      1
                    weights[old_neighbor] <- weights[old_neighbor] - 
                      1
                  }
              }
          }
      }
      else {
          warning("'", deparse(substitute(node)), "' is not a node in 'x'.", 
              "Returning 'x' unmodified.")
      }
      return(x)
  }
  <bytecode: 0x2b11648>
  <environment: namespace:SeqNet>
   --- function search by body ---
  Function rewire_connections_to_node.matrix in namespace SeqNet has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 2. Error: counts can be generated (@test_gen_counts.R#5)  -------------------
  the condition has length > 1
  Backtrace:
   1. SeqNet::gen_rnaseq(...)
   4. SeqNet::random_network(20)
   5. SeqNet::create_modules_for_network(n_modules, p, ...)
   6. SeqNet::random_module(nodes, weights = deg[nodes], ...)
   7. SeqNet::random_module_structure(length(nodes), ...)
   9. SeqNet:::rewire_connections_to_node.matrix(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  SeqNet
   --- call from context --- 
  rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
   --- call from argument --- 
  if (!(class(x) == "matrix")) stop(paste0("'", deparse(substitute(x)), 
      "' is not a 'matrix' object."))
   --- R stacktrace ---
  where 1: rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
  where 2: rewire_connections_to_node(adj, i, prob_rewire, weights, alpha, 
      beta, epsilon, run_checks = FALSE, ...)
  where 3 at testthat/test_network_node_names.R#5: random_module_structure(10)
  where 4: eval(code, test_env)
  where 5: eval(code, test_env)
  where 6: 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 7: doTryCatch(return(expr), name, parentenv, handler)
  where 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 9: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 10: doTryCatch(return(expr), name, parentenv, handler)
  where 11: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 12: tryCatchList(expr, classes, parentenv, handlers)
  where 13: 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 14: test_code(desc, code, env = parent.frame())
  where 15 at testthat/test_network_node_names.R#1: testthat::test_that("network module names are indexing correctly.", 
      {
          network <- create_empty_network(20)
          network <- set_node_names(network, 1:20)
          module <- create_empty_module(11:20)
          struct <- random_module_structure(10)
          module <- set_module_edges(module, struct)
          network <- add_modules_to_network(network, module)
          adj <- get_adjacency_matrix(network)
          empty_struct <- matrix(0, 10, 10)
          colnames(empty_struct) <- 1:10
          module_struct <- get_adjacency_matrix(module)
          expect_equal(adj[1:10, 1:10], empty_struct)
          expect_equal(adj[11:20, 11:20], module_struct)
          network <- random_network(100, avg_module_size = 20, 
              sd_module_size = 10, n_modules = 5, consistent_connections = TRUE)
          adj <- get_adjacency_matrix(network)
          mod5 <- network$modules[[5]]
          adj_mod5 <- get_adjacency_matrix(mod5)
          index <- mod5$nodes
          expect_equal(adj[index, index], adj_mod5)
      })
  where 16: eval(code, test_env)
  where 17: eval(code, test_env)
  where 18: 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 19: doTryCatch(return(expr), name, parentenv, handler)
  where 20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 21: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 22: doTryCatch(return(expr), name, parentenv, handler)
  where 23: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 24: tryCatchList(expr, classes, parentenv, handlers)
  where 25: 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 26: test_code(NULL, exprs, env)
  where 27: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: 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 33: FUN(X[[i]], ...)
  where 34: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 35: force(code)
  where 36: doWithOneRestart(return(expr), restart)
  where 37: withOneRestart(expr, restarts[[1L]])
  where 38: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 39: 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 40: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: 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 42: 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 43: test_check("SeqNet")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (x, node, prob_rewire = 1, weights = NULL, alpha = 100, 
      beta = 1, epsilon = 10^-5, run_checks = TRUE, ...) 
  {
      if (!(class(x) == "matrix")) 
          stop(paste0("'", deparse(substitute(x)), "' is not a 'matrix' object."))
      if (run_checks && is_weighted(x)) {
          warning("'", deparse(substitute(x)), "' is weighted.", 
              "Edge weights are removed prior to rewiring.")
          x <- remove_weights(x)
      }
      if (run_checks && !is_adjacency_cpp(x)) {
          stop("'", deparse(substitute(x)), "' is not an adjacency matrix.")
      }
      nodes <- get_node_names(x)
      p <- length(nodes)
      if (node <= 0) 
          stop("Argument 'node' must be a positive integer.")
      if (prob_rewire < 0 || prob_rewire > 1) 
          stop("Argument 'prob_rewire' must be in [0, 1].")
      if (!is.null(weights) && (length(weights) != p || !is.numeric(weights))) 
          stop("'", deparse(substitute(weights)), "' is not a numeric vector of length", 
              " equal to the number of nodes in m.")
      if (is.null(weights)) {
          weights <- rep(0, p)
      }
      if (node %in% nodes) {
          node_index <- which(node == nodes)
          degree <- colSums(x)
          weights <- weights + degree
          if (degree[node_index] > 0 && degree[node_index] != (p - 
              1)) {
              neighbors <- which(x[, node_index] != 0)
              available <- (1:p)[-c(node_index, neighbors)]
              n_rewire <- sum(runif(length(neighbors)) < prob_rewire)
              if (n_rewire > 0) {
                  if (length(neighbors) == 1) {
                    neighbors <- neighbors
                  }
                  else {
                    neighbors <- sample(neighbors, n_rewire)
                  }
                  for (old_neighbor in neighbors) {
                    if (length(available) == 1) {
                      new_neighbor <- available
                    }
                    else {
                      new_neighbor <- sample(available, 1, prob = pbeta(ecdf_cpp(weights[available]), 
                        alpha, beta) + epsilon)
                    }
                    x[old_neighbor, node_index] <- 0
                    x[node_index, old_neighbor] <- 0
                    x[new_neighbor, node_index] <- 1
                    x[node_index, new_neighbor] <- 1
                    available[which(available == new_neighbor)] <- old_neighbor
                    weights[new_neighbor] <- weights[new_neighbor] + 
                      1
                    weights[old_neighbor] <- weights[old_neighbor] - 
                      1
                  }
              }
          }
      }
      else {
          warning("'", deparse(substitute(node)), "' is not a node in 'x'.", 
              "Returning 'x' unmodified.")
      }
      return(x)
  }
  <bytecode: 0x2b11648>
  <environment: namespace:SeqNet>
   --- function search by body ---
  Function rewire_connections_to_node.matrix in namespace SeqNet has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 3. Error: network module names are indexing correctly. (@test_network_node_na
  the condition has length > 1
  Backtrace:
   1. SeqNet::random_module_structure(10)
   3. SeqNet:::rewire_connections_to_node.matrix(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  SeqNet
   --- call from context --- 
  rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
   --- call from argument --- 
  if (!(class(x) == "matrix")) stop(paste0("'", deparse(substitute(x)), 
      "' is not a 'matrix' object."))
   --- R stacktrace ---
  where 1: rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
  where 2: rewire_connections_to_node(adj, i, prob_rewire, weights, alpha, 
      beta, epsilon, run_checks = FALSE, ...)
  where 3: random_module_structure(length(nodes), ...)
  where 4: random_module(nodes, weights = deg[nodes], ...)
  where 5: create_modules_for_network(n_modules, p, ...)
  where 6 at testthat/test_network_structure.R#10: random_network(10, neig_size = 1, min_module_size = 10, prob_rewire = 0, 
      prob_remove = 0)
  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_network_structure.R#1: testthat::test_that("networks have appropriate structure.", {
      network <- create_empty_network(10)
      adj <- get_adjacency_matrix(network)
      expect_true(all(adj == 0))
      network <- random_network(10, n_modules = 0)
      adj <- get_adjacency_matrix(network)
      expect_true(all(adj == 0))
      network <- random_network(10, neig_size = 1, min_module_size = 10, 
          prob_rewire = 0, prob_remove = 0)
      vals <- get_network_characteristics(network)
      expect_equal(vals$p, 10)
      expect_equal(vals$n_edges, 10)
      expect_equal(vals$`avg degree`, 2)
      expect_equal(vals$`clustering coef`, 0)
      expect_equal(vals$`avg path length`, 25/9)
      network <- random_network(50, neig_size = 3, avg_module_size = 100, 
          min_module_size = 50, prob_rewire = 0, prob_remove = 0)
      vals <- get_network_characteristics(network)
      expect_equal(vals$p, 50)
      expect_equal(vals$n_edges, 150)
      expect_equal(vals$`avg degree`, 6)
      expect_equal(vals$`clustering coef`, 0.6)
      expect_equal(round(vals$`avg path length`, 3), 4.592)
      nw <- matrix(1, 2, 2)
      nw[1, -1] <- 0.8
      nw[-1, 1] <- 0.8
      nw <- create_network_from_association_matrix(nw)
      adj <- unname(get_adjacency_matrix(nw))
      expect_equal(adj[1, 2], adj[2, 1])
      expect_equal(adj[1, 1], adj[2, 2])
      expect_equal(adj[1, 1], 0)
      assoc <- unname(get_association_matrix(nw))
      expect_equal(assoc[1, 2], 0.8)
      expect_equal(assoc[2, 1], 0.8)
      expect_equal(assoc[1, 1], assoc[2, 2])
      expect_equal(assoc[1, 1], 0)
  })
  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("SeqNet")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (x, node, prob_rewire = 1, weights = NULL, alpha = 100, 
      beta = 1, epsilon = 10^-5, run_checks = TRUE, ...) 
  {
      if (!(class(x) == "matrix")) 
          stop(paste0("'", deparse(substitute(x)), "' is not a 'matrix' object."))
      if (run_checks && is_weighted(x)) {
          warning("'", deparse(substitute(x)), "' is weighted.", 
              "Edge weights are removed prior to rewiring.")
          x <- remove_weights(x)
      }
      if (run_checks && !is_adjacency_cpp(x)) {
          stop("'", deparse(substitute(x)), "' is not an adjacency matrix.")
      }
      nodes <- get_node_names(x)
      p <- length(nodes)
      if (node <= 0) 
          stop("Argument 'node' must be a positive integer.")
      if (prob_rewire < 0 || prob_rewire > 1) 
          stop("Argument 'prob_rewire' must be in [0, 1].")
      if (!is.null(weights) && (length(weights) != p || !is.numeric(weights))) 
          stop("'", deparse(substitute(weights)), "' is not a numeric vector of length", 
              " equal to the number of nodes in m.")
      if (is.null(weights)) {
          weights <- rep(0, p)
      }
      if (node %in% nodes) {
          node_index <- which(node == nodes)
          degree <- colSums(x)
          weights <- weights + degree
          if (degree[node_index] > 0 && degree[node_index] != (p - 
              1)) {
              neighbors <- which(x[, node_index] != 0)
              available <- (1:p)[-c(node_index, neighbors)]
              n_rewire <- sum(runif(length(neighbors)) < prob_rewire)
              if (n_rewire > 0) {
                  if (length(neighbors) == 1) {
                    neighbors <- neighbors
                  }
                  else {
                    neighbors <- sample(neighbors, n_rewire)
                  }
                  for (old_neighbor in neighbors) {
                    if (length(available) == 1) {
                      new_neighbor <- available
                    }
                    else {
                      new_neighbor <- sample(available, 1, prob = pbeta(ecdf_cpp(weights[available]), 
                        alpha, beta) + epsilon)
                    }
                    x[old_neighbor, node_index] <- 0
                    x[node_index, old_neighbor] <- 0
                    x[new_neighbor, node_index] <- 1
                    x[node_index, new_neighbor] <- 1
                    available[which(available == new_neighbor)] <- old_neighbor
                    weights[new_neighbor] <- weights[new_neighbor] + 
                      1
                    weights[old_neighbor] <- weights[old_neighbor] - 
                      1
                  }
              }
          }
      }
      else {
          warning("'", deparse(substitute(node)), "' is not a node in 'x'.", 
              "Returning 'x' unmodified.")
      }
      return(x)
  }
  <bytecode: 0x2b11648>
  <environment: namespace:SeqNet>
   --- function search by body ---
  Function rewire_connections_to_node.matrix in namespace SeqNet has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 4. Error: networks have appropriate structure. (@test_network_structure.R#10)
  the condition has length > 1
  Backtrace:
   1. SeqNet::random_network(...)
   2. SeqNet::create_modules_for_network(n_modules, p, ...)
   3. SeqNet::random_module(nodes, weights = deg[nodes], ...)
   4. SeqNet::random_module_structure(length(nodes), ...)
   6. SeqNet:::rewire_connections_to_node.matrix(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  SeqNet
   --- call from context --- 
  rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
   --- call from argument --- 
  if (!(class(x) == "matrix")) stop(paste0("'", deparse(substitute(x)), 
      "' is not a 'matrix' object."))
   --- R stacktrace ---
  where 1: rewire_connections_to_node.matrix(adj, i, prob_rewire, weights, 
      alpha, beta, epsilon, run_checks = FALSE, ...)
  where 2: rewire_connections_to_node(adj, i, prob_rewire, weights, alpha, 
      beta, epsilon, run_checks = FALSE, ...)
  where 3: random_module_structure(length(nodes), ...)
  where 4: random_module(nodes, weights = deg[nodes], ...)
  where 5: create_modules_for_network(n_modules, p, ...)
  where 6 at testthat/test_random_network.R#2: random_network(100)
  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_random_network.R#1: testthat::test_that("networks structures can be created", {
      network <- random_network(100)
      expect_is(network, "network")
      expect_is(network$modules[[1]], "network_module")
  })
  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("SeqNet")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (x, node, prob_rewire = 1, weights = NULL, alpha = 100, 
      beta = 1, epsilon = 10^-5, run_checks = TRUE, ...) 
  {
      if (!(class(x) == "matrix")) 
          stop(paste0("'", deparse(substitute(x)), "' is not a 'matrix' object."))
      if (run_checks && is_weighted(x)) {
          warning("'", deparse(substitute(x)), "' is weighted.", 
              "Edge weights are removed prior to rewiring.")
          x <- remove_weights(x)
      }
      if (run_checks && !is_adjacency_cpp(x)) {
          stop("'", deparse(substitute(x)), "' is not an adjacency matrix.")
      }
      nodes <- get_node_names(x)
      p <- length(nodes)
      if (node <= 0) 
          stop("Argument 'node' must be a positive integer.")
      if (prob_rewire < 0 || prob_rewire > 1) 
          stop("Argument 'prob_rewire' must be in [0, 1].")
      if (!is.null(weights) && (length(weights) != p || !is.numeric(weights))) 
          stop("'", deparse(substitute(weights)), "' is not a numeric vector of length", 
              " equal to the number of nodes in m.")
      if (is.null(weights)) {
          weights <- rep(0, p)
      }
      if (node %in% nodes) {
          node_index <- which(node == nodes)
          degree <- colSums(x)
          weights <- weights + degree
          if (degree[node_index] > 0 && degree[node_index] != (p - 
              1)) {
              neighbors <- which(x[, node_index] != 0)
              available <- (1:p)[-c(node_index, neighbors)]
              n_rewire <- sum(runif(length(neighbors)) < prob_rewire)
              if (n_rewire > 0) {
                  if (length(neighbors) == 1) {
                    neighbors <- neighbors
                  }
                  else {
                    neighbors <- sample(neighbors, n_rewire)
                  }
                  for (old_neighbor in neighbors) {
                    if (length(available) == 1) {
                      new_neighbor <- available
                    }
                    else {
                      new_neighbor <- sample(available, 1, prob = pbeta(ecdf_cpp(weights[available]), 
                        alpha, beta) + epsilon)
                    }
                    x[old_neighbor, node_index] <- 0
                    x[node_index, old_neighbor] <- 0
                    x[new_neighbor, node_index] <- 1
                    x[node_index, new_neighbor] <- 1
                    available[which(available == new_neighbor)] <- old_neighbor
                    weights[new_neighbor] <- weights[new_neighbor] + 
                      1
                    weights[old_neighbor] <- weights[old_neighbor] - 
                      1
                  }
              }
          }
      }
      else {
          warning("'", deparse(substitute(node)), "' is not a node in 'x'.", 
              "Returning 'x' unmodified.")
      }
      return(x)
  }
  <bytecode: 0x2b11648>
  <environment: namespace:SeqNet>
   --- function search by body ---
  Function rewire_connections_to_node.matrix in namespace SeqNet has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 5. Error: networks structures can be created (@test_random_network.R#2)  ----
  the condition has length > 1
  Backtrace:
   1. SeqNet::random_network(100)
   2. SeqNet::create_modules_for_network(n_modules, p, ...)
   3. SeqNet::random_module(nodes, weights = deg[nodes], ...)
   4. SeqNet::random_module_structure(length(nodes), ...)
   6. SeqNet:::rewire_connections_to_node.matrix(...)
  
  == testthat results  ===========================================================
  [ OK: 19 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 5 ]
  1. Error: networks can be created from matricies (@test_create_network.R#2) 
  2. Error: counts can be generated (@test_gen_counts.R#5) 
  3. Error: network module names are indexing correctly. (@test_network_node_names.R#5) 
  4. Error: networks have appropriate structure. (@test_network_structure.R#10) 
  5. Error: networks structures can be created (@test_random_network.R#2) 
  
  Error: testthat unit tests failed
  Execution halted