Running 'testthat.R' [3s/4s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(bmotif)
  > 
  > test_check("bmotif")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  mcount(matrix("a", 3, 3))
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: mcount(matrix("a", 3, 3))
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_mcount.R#3: expect_error(object = mcount(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
  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_mcount.R#1: test_that("mcount behaves as expected", {
      expect_error(object = mcount("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = mcount(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = mcount(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = TRUE, 
          normalise = 7), "'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = 7, 
          normalise = TRUE), "'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = FALSE), 
          mcount_SF_NF)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = FALSE), 
          mcount_ST_NF)
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = TRUE), 
          mcount_SF_NT)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = TRUE), 
          mcount_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = TRUE), 
          mcount_transpose_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = TRUE), 
          mcount_transpose_SF_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = FALSE), 
          mcount_transpose_ST_NF)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = FALSE), 
          mcount_transpose_SF_NF)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, normalise) 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length zero")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(normalise) != "logical") {
          stop("'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      }
      if (class(six_node) != "logical") {
          stop("'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      }
      M[M > 0] <- 1
      dimnames(M) <- NULL
      p <- dim(M)[2]
      z <- dim(M)[1]
      J <- matrix(rep(1, z * p), nrow = z, ncol = p)
      JP <- matrix(rep(1, p * p), nrow = p, ncol = p)
      JZ <- matrix(rep(1, z * z), nrow = z, ncol = z)
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      dP <- apply(M, MARGIN = 2, sum)
      jP <- rep(1, p)
      dZ <- apply(M, MARGIN = 1, sum)
      jZ <- rep(1, z)
      if (six_node == TRUE) {
          if (p < z) {
              J3 <- array(rep(1, p * p * p), c(p, p, p))
              AP <- maketensor(M, M)
              BP <- maketensor(M, N)
              CP <- maketensor(N, M)
              DP <- maketensor(N, N)
              MA <- tensor::tensor(MT, AP, 2, 1)
              MB <- tensor::tensor(MT, BP, 2, 1)
              MC <- tensor::tensor(MT, CP, 2, 1)
              MD <- tensor::tensor(MT, DP, 2, 1)
              Na <- tensor::tensor(NT, AP, 2, 1)
              NB <- tensor::tensor(NT, BP, 2, 1)
              NC <- tensor::tensor(NT, CP, 2, 1)
              K3 <- J3
              for (i in 1:p) {
                  for (j in 1:p) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          if (p >= z) {
              J3 <- array(rep(1, z * z * z), c(z, z, z))
              AP <- maketensor(MT, MT)
              BP <- maketensor(MT, NT)
              CP <- maketensor(NT, MT)
              DP <- maketensor(NT, NT)
              MA <- tensor::tensor(M, AP, 2, 1)
              MB <- tensor::tensor(M, BP, 2, 1)
              MC <- tensor::tensor(M, CP, 2, 1)
              MD <- tensor::tensor(M, DP, 2, 1)
              Na <- tensor::tensor(N, AP, 2, 1)
              NB <- tensor::tensor(N, BP, 2, 1)
              NC <- tensor::tensor(N, CP, 2, 1)
              K3 <- J3
              for (i in 1:z) {
                  for (j in 1:z) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          MA <- MA * K3
          MB <- MB * K3
          MC <- MC * K3
          MD <- MD * K3
          Na <- Na * K3
          NB <- NB * K3
          NC <- NC * K3
      }
      if (six_node == FALSE) {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA, normalise_sum = NA, 
                  normalise_sizeclass = NA, normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA)
          }
      }
      else {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA, 
                  normalise_sum = NA, normalise_sizeclass = NA, 
                  normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA)
          }
      }
      if (six_node == FALSE) {
          for (i in 1:17) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ)
          }
      }
      else {
          for (i in 1:44) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ, J3 = J3, MA = MA, MB = MB, 
                  MC = MC, MD = MD, Na = Na, NB = NB, NC = NC)
          }
      }
      if (normalise == TRUE) {
          out$normalise_sum <- out$frequency/sum(out$frequency)
          out$normalise_sizeclass <- do.call("c", lapply(split(out, 
              out$nodes), function(df) df$frequency/sum(df$frequency)))
          sets <- node_sets(M, six_node = six_node)
          out$normalise_nodesets <- out$frequency/sets
      }
      return(out)
  }
  <bytecode: 0x46ade90>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function mcount in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Failure: mcount behaves as expected (@test_mcount.R#3)  ------------------
  `mcount(matrix("a", 3, 3))` threw an error with unexpected message.
  Expected match: "Elements of 'M' must be numeric"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(object = mcount(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
   6. bmotif::mcount(matrix("a", 3, 3))
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  mcount(matrix(-1, 3, 3))
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: mcount(matrix(-1, 3, 3))
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_mcount.R#4: expect_error(object = mcount(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
  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_mcount.R#1: test_that("mcount behaves as expected", {
      expect_error(object = mcount("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = mcount(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = mcount(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = TRUE, 
          normalise = 7), "'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = 7, 
          normalise = TRUE), "'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = FALSE), 
          mcount_SF_NF)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = FALSE), 
          mcount_ST_NF)
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = TRUE), 
          mcount_SF_NT)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = TRUE), 
          mcount_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = TRUE), 
          mcount_transpose_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = TRUE), 
          mcount_transpose_SF_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = FALSE), 
          mcount_transpose_ST_NF)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = FALSE), 
          mcount_transpose_SF_NF)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, normalise) 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length zero")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(normalise) != "logical") {
          stop("'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      }
      if (class(six_node) != "logical") {
          stop("'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      }
      M[M > 0] <- 1
      dimnames(M) <- NULL
      p <- dim(M)[2]
      z <- dim(M)[1]
      J <- matrix(rep(1, z * p), nrow = z, ncol = p)
      JP <- matrix(rep(1, p * p), nrow = p, ncol = p)
      JZ <- matrix(rep(1, z * z), nrow = z, ncol = z)
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      dP <- apply(M, MARGIN = 2, sum)
      jP <- rep(1, p)
      dZ <- apply(M, MARGIN = 1, sum)
      jZ <- rep(1, z)
      if (six_node == TRUE) {
          if (p < z) {
              J3 <- array(rep(1, p * p * p), c(p, p, p))
              AP <- maketensor(M, M)
              BP <- maketensor(M, N)
              CP <- maketensor(N, M)
              DP <- maketensor(N, N)
              MA <- tensor::tensor(MT, AP, 2, 1)
              MB <- tensor::tensor(MT, BP, 2, 1)
              MC <- tensor::tensor(MT, CP, 2, 1)
              MD <- tensor::tensor(MT, DP, 2, 1)
              Na <- tensor::tensor(NT, AP, 2, 1)
              NB <- tensor::tensor(NT, BP, 2, 1)
              NC <- tensor::tensor(NT, CP, 2, 1)
              K3 <- J3
              for (i in 1:p) {
                  for (j in 1:p) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          if (p >= z) {
              J3 <- array(rep(1, z * z * z), c(z, z, z))
              AP <- maketensor(MT, MT)
              BP <- maketensor(MT, NT)
              CP <- maketensor(NT, MT)
              DP <- maketensor(NT, NT)
              MA <- tensor::tensor(M, AP, 2, 1)
              MB <- tensor::tensor(M, BP, 2, 1)
              MC <- tensor::tensor(M, CP, 2, 1)
              MD <- tensor::tensor(M, DP, 2, 1)
              Na <- tensor::tensor(N, AP, 2, 1)
              NB <- tensor::tensor(N, BP, 2, 1)
              NC <- tensor::tensor(N, CP, 2, 1)
              K3 <- J3
              for (i in 1:z) {
                  for (j in 1:z) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          MA <- MA * K3
          MB <- MB * K3
          MC <- MC * K3
          MD <- MD * K3
          Na <- Na * K3
          NB <- NB * K3
          NC <- NC * K3
      }
      if (six_node == FALSE) {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA, normalise_sum = NA, 
                  normalise_sizeclass = NA, normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA)
          }
      }
      else {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA, 
                  normalise_sum = NA, normalise_sizeclass = NA, 
                  normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA)
          }
      }
      if (six_node == FALSE) {
          for (i in 1:17) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ)
          }
      }
      else {
          for (i in 1:44) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ, J3 = J3, MA = MA, MB = MB, 
                  MC = MC, MD = MD, Na = Na, NB = NB, NC = NC)
          }
      }
      if (normalise == TRUE) {
          out$normalise_sum <- out$frequency/sum(out$frequency)
          out$normalise_sizeclass <- do.call("c", lapply(split(out, 
              out$nodes), function(df) df$frequency/sum(df$frequency)))
          sets <- node_sets(M, six_node = six_node)
          out$normalise_nodesets <- out$frequency/sets
      }
      return(out)
  }
  <bytecode: 0x46ade90>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function mcount in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 2. Failure: mcount behaves as expected (@test_mcount.R#4)  ------------------
  `mcount(matrix(-1, 3, 3))` threw an error with unexpected message.
  Expected match: "Elements of 'M' must be greater than or equal to zero"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(object = mcount(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
   6. bmotif::mcount(matrix(-1, 3, 3))
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  mcount(matrix(1, 3, 3), six_node = TRUE, normalise = 7)
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: mcount(matrix(1, 3, 3), six_node = TRUE, normalise = 7)
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_mcount.R#5: expect_error(object = mcount(matrix(1, 3, 3), six_node = TRUE, 
      normalise = 7), "'normalise' must be of class 'logical' i.e. TRUE or FALSE")
  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_mcount.R#1: test_that("mcount behaves as expected", {
      expect_error(object = mcount("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = mcount(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = mcount(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = TRUE, 
          normalise = 7), "'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = 7, 
          normalise = TRUE), "'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = FALSE), 
          mcount_SF_NF)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = FALSE), 
          mcount_ST_NF)
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = TRUE), 
          mcount_SF_NT)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = TRUE), 
          mcount_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = TRUE), 
          mcount_transpose_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = TRUE), 
          mcount_transpose_SF_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = FALSE), 
          mcount_transpose_ST_NF)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = FALSE), 
          mcount_transpose_SF_NF)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, normalise) 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length zero")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(normalise) != "logical") {
          stop("'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      }
      if (class(six_node) != "logical") {
          stop("'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      }
      M[M > 0] <- 1
      dimnames(M) <- NULL
      p <- dim(M)[2]
      z <- dim(M)[1]
      J <- matrix(rep(1, z * p), nrow = z, ncol = p)
      JP <- matrix(rep(1, p * p), nrow = p, ncol = p)
      JZ <- matrix(rep(1, z * z), nrow = z, ncol = z)
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      dP <- apply(M, MARGIN = 2, sum)
      jP <- rep(1, p)
      dZ <- apply(M, MARGIN = 1, sum)
      jZ <- rep(1, z)
      if (six_node == TRUE) {
          if (p < z) {
              J3 <- array(rep(1, p * p * p), c(p, p, p))
              AP <- maketensor(M, M)
              BP <- maketensor(M, N)
              CP <- maketensor(N, M)
              DP <- maketensor(N, N)
              MA <- tensor::tensor(MT, AP, 2, 1)
              MB <- tensor::tensor(MT, BP, 2, 1)
              MC <- tensor::tensor(MT, CP, 2, 1)
              MD <- tensor::tensor(MT, DP, 2, 1)
              Na <- tensor::tensor(NT, AP, 2, 1)
              NB <- tensor::tensor(NT, BP, 2, 1)
              NC <- tensor::tensor(NT, CP, 2, 1)
              K3 <- J3
              for (i in 1:p) {
                  for (j in 1:p) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          if (p >= z) {
              J3 <- array(rep(1, z * z * z), c(z, z, z))
              AP <- maketensor(MT, MT)
              BP <- maketensor(MT, NT)
              CP <- maketensor(NT, MT)
              DP <- maketensor(NT, NT)
              MA <- tensor::tensor(M, AP, 2, 1)
              MB <- tensor::tensor(M, BP, 2, 1)
              MC <- tensor::tensor(M, CP, 2, 1)
              MD <- tensor::tensor(M, DP, 2, 1)
              Na <- tensor::tensor(N, AP, 2, 1)
              NB <- tensor::tensor(N, BP, 2, 1)
              NC <- tensor::tensor(N, CP, 2, 1)
              K3 <- J3
              for (i in 1:z) {
                  for (j in 1:z) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          MA <- MA * K3
          MB <- MB * K3
          MC <- MC * K3
          MD <- MD * K3
          Na <- Na * K3
          NB <- NB * K3
          NC <- NC * K3
      }
      if (six_node == FALSE) {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA, normalise_sum = NA, 
                  normalise_sizeclass = NA, normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA)
          }
      }
      else {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA, 
                  normalise_sum = NA, normalise_sizeclass = NA, 
                  normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA)
          }
      }
      if (six_node == FALSE) {
          for (i in 1:17) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ)
          }
      }
      else {
          for (i in 1:44) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ, J3 = J3, MA = MA, MB = MB, 
                  MC = MC, MD = MD, Na = Na, NB = NB, NC = NC)
          }
      }
      if (normalise == TRUE) {
          out$normalise_sum <- out$frequency/sum(out$frequency)
          out$normalise_sizeclass <- do.call("c", lapply(split(out, 
              out$nodes), function(df) df$frequency/sum(df$frequency)))
          sets <- node_sets(M, six_node = six_node)
          out$normalise_nodesets <- out$frequency/sets
      }
      return(out)
  }
  <bytecode: 0x46ade90>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function mcount in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 3. Failure: mcount behaves as expected (@test_mcount.R#5)  ------------------
  `mcount(matrix(1, 3, 3), six_node = TRUE, normalise = 7)` threw an error with unexpected message.
  Expected match: "'normalise' must be of class 'logical' i.e. TRUE or FALSE"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::mcount(matrix(1, 3, 3), six_node = TRUE, normalise = 7)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  mcount(matrix(1, 3, 3), six_node = 7, normalise = TRUE)
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: mcount(matrix(1, 3, 3), six_node = 7, normalise = TRUE)
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_mcount.R#6: expect_error(object = mcount(matrix(1, 3, 3), six_node = 7, normalise = TRUE), 
      "'six_node' must be of class 'logical' i.e. TRUE or FALSE")
  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_mcount.R#1: test_that("mcount behaves as expected", {
      expect_error(object = mcount("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = mcount(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = mcount(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = TRUE, 
          normalise = 7), "'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = 7, 
          normalise = TRUE), "'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = FALSE), 
          mcount_SF_NF)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = FALSE), 
          mcount_ST_NF)
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = TRUE), 
          mcount_SF_NT)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = TRUE), 
          mcount_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = TRUE), 
          mcount_transpose_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = TRUE), 
          mcount_transpose_SF_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = FALSE), 
          mcount_transpose_ST_NF)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = FALSE), 
          mcount_transpose_SF_NF)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, normalise) 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length zero")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(normalise) != "logical") {
          stop("'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      }
      if (class(six_node) != "logical") {
          stop("'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      }
      M[M > 0] <- 1
      dimnames(M) <- NULL
      p <- dim(M)[2]
      z <- dim(M)[1]
      J <- matrix(rep(1, z * p), nrow = z, ncol = p)
      JP <- matrix(rep(1, p * p), nrow = p, ncol = p)
      JZ <- matrix(rep(1, z * z), nrow = z, ncol = z)
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      dP <- apply(M, MARGIN = 2, sum)
      jP <- rep(1, p)
      dZ <- apply(M, MARGIN = 1, sum)
      jZ <- rep(1, z)
      if (six_node == TRUE) {
          if (p < z) {
              J3 <- array(rep(1, p * p * p), c(p, p, p))
              AP <- maketensor(M, M)
              BP <- maketensor(M, N)
              CP <- maketensor(N, M)
              DP <- maketensor(N, N)
              MA <- tensor::tensor(MT, AP, 2, 1)
              MB <- tensor::tensor(MT, BP, 2, 1)
              MC <- tensor::tensor(MT, CP, 2, 1)
              MD <- tensor::tensor(MT, DP, 2, 1)
              Na <- tensor::tensor(NT, AP, 2, 1)
              NB <- tensor::tensor(NT, BP, 2, 1)
              NC <- tensor::tensor(NT, CP, 2, 1)
              K3 <- J3
              for (i in 1:p) {
                  for (j in 1:p) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          if (p >= z) {
              J3 <- array(rep(1, z * z * z), c(z, z, z))
              AP <- maketensor(MT, MT)
              BP <- maketensor(MT, NT)
              CP <- maketensor(NT, MT)
              DP <- maketensor(NT, NT)
              MA <- tensor::tensor(M, AP, 2, 1)
              MB <- tensor::tensor(M, BP, 2, 1)
              MC <- tensor::tensor(M, CP, 2, 1)
              MD <- tensor::tensor(M, DP, 2, 1)
              Na <- tensor::tensor(N, AP, 2, 1)
              NB <- tensor::tensor(N, BP, 2, 1)
              NC <- tensor::tensor(N, CP, 2, 1)
              K3 <- J3
              for (i in 1:z) {
                  for (j in 1:z) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          MA <- MA * K3
          MB <- MB * K3
          MC <- MC * K3
          MD <- MD * K3
          Na <- Na * K3
          NB <- NB * K3
          NC <- NC * K3
      }
      if (six_node == FALSE) {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA, normalise_sum = NA, 
                  normalise_sizeclass = NA, normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA)
          }
      }
      else {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA, 
                  normalise_sum = NA, normalise_sizeclass = NA, 
                  normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA)
          }
      }
      if (six_node == FALSE) {
          for (i in 1:17) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ)
          }
      }
      else {
          for (i in 1:44) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ, J3 = J3, MA = MA, MB = MB, 
                  MC = MC, MD = MD, Na = Na, NB = NB, NC = NC)
          }
      }
      if (normalise == TRUE) {
          out$normalise_sum <- out$frequency/sum(out$frequency)
          out$normalise_sizeclass <- do.call("c", lapply(split(out, 
              out$nodes), function(df) df$frequency/sum(df$frequency)))
          sets <- node_sets(M, six_node = six_node)
          out$normalise_nodesets <- out$frequency/sets
      }
      return(out)
  }
  <bytecode: 0x46ade90>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function mcount in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 4. Failure: mcount behaves as expected (@test_mcount.R#6)  ------------------
  `mcount(matrix(1, 3, 3), six_node = 7, normalise = TRUE)` threw an error with unexpected message.
  Expected match: "'six_node' must be of class 'logical' i.e. TRUE or FALSE"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::mcount(matrix(1, 3, 3), six_node = 7, normalise = TRUE)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  mcount(M = mat, six_node = FALSE, normalise = FALSE)
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: mcount(M = mat, six_node = FALSE, normalise = FALSE)
  where 2: eval_bare(expr, quo_get_env(quo))
  where 3: quasi_label(enquo(object), label, arg = "object")
  where 4 at testthat/test_mcount.R#8: expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = FALSE), 
      mcount_SF_NF)
  where 5: eval(code, test_env)
  where 6: eval(code, test_env)
  where 7: 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 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 10: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 11: doTryCatch(return(expr), name, parentenv, handler)
  where 12: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 13: tryCatchList(expr, classes, parentenv, handlers)
  where 14: 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 15: test_code(desc, code, env = parent.frame())
  where 16 at testthat/test_mcount.R#1: test_that("mcount behaves as expected", {
      expect_error(object = mcount("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = mcount(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = mcount(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = TRUE, 
          normalise = 7), "'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      expect_error(object = mcount(matrix(1, 3, 3), six_node = 7, 
          normalise = TRUE), "'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = FALSE), 
          mcount_SF_NF)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = FALSE), 
          mcount_ST_NF)
      expect_equal(object = mcount(M = mat, six_node = FALSE, normalise = TRUE), 
          mcount_SF_NT)
      expect_equal(object = mcount(M = mat, six_node = TRUE, normalise = TRUE), 
          mcount_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = TRUE), 
          mcount_transpose_ST_NT)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = TRUE), 
          mcount_transpose_SF_NT)
      expect_equal(mcount(M = t(mat), six_node = TRUE, normalise = FALSE), 
          mcount_transpose_ST_NF)
      expect_equal(mcount(M = t(mat), six_node = FALSE, normalise = FALSE), 
          mcount_transpose_SF_NF)
  })
  where 17: eval(code, test_env)
  where 18: eval(code, test_env)
  where 19: 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 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 22: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 23: doTryCatch(return(expr), name, parentenv, handler)
  where 24: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 25: tryCatchList(expr, classes, parentenv, handlers)
  where 26: 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 27: test_code(NULL, exprs, env)
  where 28: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 29: force(code)
  where 30: doWithOneRestart(return(expr), restart)
  where 31: withOneRestart(expr, restarts[[1L]])
  where 32: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 33: 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 34: FUN(X[[i]], ...)
  where 35: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 36: force(code)
  where 37: doWithOneRestart(return(expr), restart)
  where 38: withOneRestart(expr, restarts[[1L]])
  where 39: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 40: 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 41: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 42: 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 43: 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 44: test_check("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, normalise) 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length zero")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(normalise) != "logical") {
          stop("'normalise' must be of class 'logical' i.e. TRUE or FALSE")
      }
      if (class(six_node) != "logical") {
          stop("'six_node' must be of class 'logical' i.e. TRUE or FALSE")
      }
      M[M > 0] <- 1
      dimnames(M) <- NULL
      p <- dim(M)[2]
      z <- dim(M)[1]
      J <- matrix(rep(1, z * p), nrow = z, ncol = p)
      JP <- matrix(rep(1, p * p), nrow = p, ncol = p)
      JZ <- matrix(rep(1, z * z), nrow = z, ncol = z)
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      dP <- apply(M, MARGIN = 2, sum)
      jP <- rep(1, p)
      dZ <- apply(M, MARGIN = 1, sum)
      jZ <- rep(1, z)
      if (six_node == TRUE) {
          if (p < z) {
              J3 <- array(rep(1, p * p * p), c(p, p, p))
              AP <- maketensor(M, M)
              BP <- maketensor(M, N)
              CP <- maketensor(N, M)
              DP <- maketensor(N, N)
              MA <- tensor::tensor(MT, AP, 2, 1)
              MB <- tensor::tensor(MT, BP, 2, 1)
              MC <- tensor::tensor(MT, CP, 2, 1)
              MD <- tensor::tensor(MT, DP, 2, 1)
              Na <- tensor::tensor(NT, AP, 2, 1)
              NB <- tensor::tensor(NT, BP, 2, 1)
              NC <- tensor::tensor(NT, CP, 2, 1)
              K3 <- J3
              for (i in 1:p) {
                  for (j in 1:p) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          if (p >= z) {
              J3 <- array(rep(1, z * z * z), c(z, z, z))
              AP <- maketensor(MT, MT)
              BP <- maketensor(MT, NT)
              CP <- maketensor(NT, MT)
              DP <- maketensor(NT, NT)
              MA <- tensor::tensor(M, AP, 2, 1)
              MB <- tensor::tensor(M, BP, 2, 1)
              MC <- tensor::tensor(M, CP, 2, 1)
              MD <- tensor::tensor(M, DP, 2, 1)
              Na <- tensor::tensor(N, AP, 2, 1)
              NB <- tensor::tensor(N, BP, 2, 1)
              NC <- tensor::tensor(N, CP, 2, 1)
              K3 <- J3
              for (i in 1:z) {
                  for (j in 1:z) {
                    K3[i, j, j] <- 0
                    K3[j, i, j] <- 0
                    K3[j, j, i] <- 0
                  }
              }
          }
          MA <- MA * K3
          MB <- MB * K3
          MC <- MC * K3
          MD <- MD * K3
          Na <- Na * K3
          NB <- NB * K3
          NC <- NC * K3
      }
      if (six_node == FALSE) {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA, normalise_sum = NA, 
                  normalise_sizeclass = NA, normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:17, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10)), frequency = NA)
          }
      }
      else {
          if (normalise == TRUE) {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA, 
                  normalise_sum = NA, normalise_sizeclass = NA, 
                  normalise_nodesets = NA)
          }
          else {
              out <- data.frame(motif = 1:44, nodes = c(2, rep(3, 
                  2), rep(4, 4), rep(5, 10), rep(6, 27)), frequency = NA)
          }
      }
      if (six_node == FALSE) {
          for (i in 1:17) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ)
          }
      }
      else {
          for (i in 1:44) {
              out[i, "frequency"] <- countmotif(x = M, motif = i, 
                  z = z, p = p, JP = JP, JZ = JZ, P = P, Q = Q, 
                  R = R, Z = Z, Y = Y, X = X, dP = dP, jP = jP, 
                  dZ = dZ, jZ = jZ, J3 = J3, MA = MA, MB = MB, 
                  MC = MC, MD = MD, Na = Na, NB = NB, NC = NC)
          }
      }
      if (normalise == TRUE) {
          out$normalise_sum <- out$frequency/sum(out$frequency)
          out$normalise_sizeclass <- do.call("c", lapply(split(out, 
              out$nodes), function(df) df$frequency/sum(df$frequency)))
          sets <- node_sets(M, six_node = six_node)
          out$normalise_nodesets <- out$frequency/sets
      }
      return(out)
  }
  <bytecode: 0x46ade90>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function mcount in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 5. Error: mcount behaves as expected (@test_mcount.R#8)  --------------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_equal(...)
   4. bmotif::mcount(M = mat, six_node = FALSE, normalise = FALSE)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  positions(matrix("a", 3, 3))
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: positions(matrix("a", 3, 3))
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_positions.R#3: expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
  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_positions.R#1: test_that("positions behaves as expected", {
      expect_error(object = positions("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = 7, normalisation = "none"), "'level' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "none"), positions_T_all_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "sum"), positions_T_all_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "size class"), positions_T_all_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "none"), positions_T_rows_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "sum"), positions_T_rows_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "size class"), positions_T_rows_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "none"), positions_T_columns_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "sum"), positions_T_columns_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "size class"), positions_T_columns_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "none"), positions_F_all_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "sum"), positions_F_all_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "size class"), positions_F_all_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "none"), positions_F_rows_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "sum"), positions_F_rows_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "size class"), positions_F_rows_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "none"), positions_F_columns_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "sum"), positions_F_columns_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "size class"), positions_F_columns_sc)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, level = "all", normalisation = "none") 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length 0")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(level) != "character") {
          stop("'level' must be of class 'character'")
      }
      if (!level %in% c("rows", "columns", "all")) {
          stop("'level' must equal 'rows', 'columns' or 'all'")
      }
      if (class(normalisation) != "character") {
          stop("'normalisation' must be of class 'character'")
      }
      if (!normalisation %in% c("none", "sum", "size class")) {
          stop("'normalisation' must equal 'none', 'sum' or 'size class'")
      }
      M[M > 0] <- 1
      if (is.null(rownames(M))) {
          rownames(M) <- paste0("R", 1:nrow(M))
          warning("M had no row names and so has been assigned default row names")
      }
      if (is.null(colnames(M))) {
          colnames(M) <- paste0("C", 1:ncol(M))
          warning("M had no column names and so has been assigned default column names")
      }
      rn <- rownames(M)
      cn <- colnames(M)
      dimnames(M) <- NULL
      Z <- nrow(M)
      P <- ncol(M)
      jZ <- matrix(rep(1, Z))
      jP <- matrix(rep(1, P))
      J <- matrix(rep(1, Z * P), nrow = Z, ncol = P)
      JP <- matrix(rep(1, P * P), nrow = P, ncol = P)
      JZ <- matrix(rep(1, Z * Z), nrow = Z, ncol = Z)
      if (six_node == TRUE) {
          JP3 <- array(rep(1, P * P * P), c(P, P, P))
          JZ3 <- array(rep(1, Z * Z * Z), c(Z, Z, Z))
          KP3 <- JP3
          for (i in 1:P) {
              for (j in 1:P) {
                  KP3[i, j, j] <- 0
                  KP3[j, i, j] <- 0
                  KP3[j, j, i] <- 0
              }
          }
          KZ3 <- JZ3
          for (i in 1:Z) {
              for (j in 1:Z) {
                  KZ3[i, j, j] <- 0
                  KZ3[j, i, j] <- 0
                  KZ3[j, j, i] <- 0
              }
          }
      }
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      dZ <- M %*% jP
      dP <- MT %*% jZ
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      if (six_node == TRUE) {
          AZ <- maketensor(M, M)
          BZ <- maketensor(M, N)
          CZ <- maketensor(N, M)
          DZ <- maketensor(N, N)
          AP <- maketensor(MT, MT)
          BP <- maketensor(MT, NT)
          CP <- maketensor(NT, MT)
          DP <- maketensor(NT, NT)
          MTA <- multtensor(MT, AZ)
          MTB <- multtensor(MT, BZ)
          MTC <- multtensor(MT, CZ)
          MTD <- multtensor(MT, DZ)
          MA <- multtensor(M, AP)
          MB <- multtensor(M, BP)
          MC <- multtensor(M, CP)
          MD <- multtensor(M, DP)
          NTA <- multtensor(NT, AZ)
          NTB <- multtensor(NT, BZ)
          NTC <- multtensor(NT, CZ)
          Na <- multtensor(N, AP)
          NB <- multtensor(N, BP)
          NC <- multtensor(N, CP)
      }
      if (six_node == FALSE) {
          pos_row <- matrix(0, ncol = 46, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:46)))
          pos_col <- matrix(0, ncol = 46, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:46)))
      }
      else {
          pos_row <- matrix(0, ncol = 148, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:148)))
          pos_col <- matrix(0, ncol = 148, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:148)))
      }
      if (six_node == FALSE) {
          for (i in 1:46) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      else {
          for (i in 1:148) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, JP3 = JP3, JZ3 = JZ3, KP3 = KP3, 
                  KZ3 = KZ3, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R, 
                  MTA = MTA, MTB = MTB, MTC = MTC, MTD = MTD, MA = MA, 
                  MB = MB, MC = MC, MD = MD, NTA = NTA, NTB = NTB, 
                  NTC = NTC, Na = Na, NB = NB, NC = NC)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      if (normalisation != "none") {
          pos_row <- normalise_positions(pc = pos_row, type = normalisation)
          pos_col <- normalise_positions(pc = pos_col, type = normalisation)
      }
      if (level == "all") {
          out <- rbind(pos_row, pos_col)
          out <- as.data.frame(out)
          return(out)
      }
      else if (level == "rows") {
          pos_row <- as.data.frame(pos_row)
          return(pos_row)
      }
      else if (level == "columns") {
          pos_col <- as.data.frame(pos_col)
          return(pos_col)
      }
  }
  <bytecode: 0x45c1628>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function positions in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 6. Failure: positions behaves as expected (@test_positions.R#3)  ------------
  `positions(matrix("a", 3, 3))` threw an error with unexpected message.
  Expected match: "Elements of 'M' must be numeric"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::positions(matrix("a", 3, 3))
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  positions(matrix(-1, 3, 3))
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: positions(matrix(-1, 3, 3))
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_positions.R#4: expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
  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_positions.R#1: test_that("positions behaves as expected", {
      expect_error(object = positions("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = 7, normalisation = "none"), "'level' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "none"), positions_T_all_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "sum"), positions_T_all_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "size class"), positions_T_all_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "none"), positions_T_rows_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "sum"), positions_T_rows_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "size class"), positions_T_rows_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "none"), positions_T_columns_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "sum"), positions_T_columns_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "size class"), positions_T_columns_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "none"), positions_F_all_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "sum"), positions_F_all_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "size class"), positions_F_all_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "none"), positions_F_rows_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "sum"), positions_F_rows_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "size class"), positions_F_rows_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "none"), positions_F_columns_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "sum"), positions_F_columns_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "size class"), positions_F_columns_sc)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, level = "all", normalisation = "none") 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length 0")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(level) != "character") {
          stop("'level' must be of class 'character'")
      }
      if (!level %in% c("rows", "columns", "all")) {
          stop("'level' must equal 'rows', 'columns' or 'all'")
      }
      if (class(normalisation) != "character") {
          stop("'normalisation' must be of class 'character'")
      }
      if (!normalisation %in% c("none", "sum", "size class")) {
          stop("'normalisation' must equal 'none', 'sum' or 'size class'")
      }
      M[M > 0] <- 1
      if (is.null(rownames(M))) {
          rownames(M) <- paste0("R", 1:nrow(M))
          warning("M had no row names and so has been assigned default row names")
      }
      if (is.null(colnames(M))) {
          colnames(M) <- paste0("C", 1:ncol(M))
          warning("M had no column names and so has been assigned default column names")
      }
      rn <- rownames(M)
      cn <- colnames(M)
      dimnames(M) <- NULL
      Z <- nrow(M)
      P <- ncol(M)
      jZ <- matrix(rep(1, Z))
      jP <- matrix(rep(1, P))
      J <- matrix(rep(1, Z * P), nrow = Z, ncol = P)
      JP <- matrix(rep(1, P * P), nrow = P, ncol = P)
      JZ <- matrix(rep(1, Z * Z), nrow = Z, ncol = Z)
      if (six_node == TRUE) {
          JP3 <- array(rep(1, P * P * P), c(P, P, P))
          JZ3 <- array(rep(1, Z * Z * Z), c(Z, Z, Z))
          KP3 <- JP3
          for (i in 1:P) {
              for (j in 1:P) {
                  KP3[i, j, j] <- 0
                  KP3[j, i, j] <- 0
                  KP3[j, j, i] <- 0
              }
          }
          KZ3 <- JZ3
          for (i in 1:Z) {
              for (j in 1:Z) {
                  KZ3[i, j, j] <- 0
                  KZ3[j, i, j] <- 0
                  KZ3[j, j, i] <- 0
              }
          }
      }
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      dZ <- M %*% jP
      dP <- MT %*% jZ
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      if (six_node == TRUE) {
          AZ <- maketensor(M, M)
          BZ <- maketensor(M, N)
          CZ <- maketensor(N, M)
          DZ <- maketensor(N, N)
          AP <- maketensor(MT, MT)
          BP <- maketensor(MT, NT)
          CP <- maketensor(NT, MT)
          DP <- maketensor(NT, NT)
          MTA <- multtensor(MT, AZ)
          MTB <- multtensor(MT, BZ)
          MTC <- multtensor(MT, CZ)
          MTD <- multtensor(MT, DZ)
          MA <- multtensor(M, AP)
          MB <- multtensor(M, BP)
          MC <- multtensor(M, CP)
          MD <- multtensor(M, DP)
          NTA <- multtensor(NT, AZ)
          NTB <- multtensor(NT, BZ)
          NTC <- multtensor(NT, CZ)
          Na <- multtensor(N, AP)
          NB <- multtensor(N, BP)
          NC <- multtensor(N, CP)
      }
      if (six_node == FALSE) {
          pos_row <- matrix(0, ncol = 46, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:46)))
          pos_col <- matrix(0, ncol = 46, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:46)))
      }
      else {
          pos_row <- matrix(0, ncol = 148, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:148)))
          pos_col <- matrix(0, ncol = 148, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:148)))
      }
      if (six_node == FALSE) {
          for (i in 1:46) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      else {
          for (i in 1:148) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, JP3 = JP3, JZ3 = JZ3, KP3 = KP3, 
                  KZ3 = KZ3, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R, 
                  MTA = MTA, MTB = MTB, MTC = MTC, MTD = MTD, MA = MA, 
                  MB = MB, MC = MC, MD = MD, NTA = NTA, NTB = NTB, 
                  NTC = NTC, Na = Na, NB = NB, NC = NC)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      if (normalisation != "none") {
          pos_row <- normalise_positions(pc = pos_row, type = normalisation)
          pos_col <- normalise_positions(pc = pos_col, type = normalisation)
      }
      if (level == "all") {
          out <- rbind(pos_row, pos_col)
          out <- as.data.frame(out)
          return(out)
      }
      else if (level == "rows") {
          pos_row <- as.data.frame(pos_row)
          return(pos_row)
      }
      else if (level == "columns") {
          pos_col <- as.data.frame(pos_col)
          return(pos_col)
      }
  }
  <bytecode: 0x45c1628>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function positions in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 7. Failure: positions behaves as expected (@test_positions.R#4)  ------------
  `positions(matrix(-1, 3, 3))` threw an error with unexpected message.
  Expected match: "Elements of 'M' must be greater than or equal to zero"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::positions(matrix(-1, 3, 3))
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  positions(matrix(1, 3, 3), six_node = TRUE, level = 7, normalisation = "none")
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: positions(matrix(1, 3, 3), six_node = TRUE, level = 7, normalisation = "none")
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_positions.R#5: expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
      level = 7, normalisation = "none"), "'level' must be of class 'character'")
  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_positions.R#1: test_that("positions behaves as expected", {
      expect_error(object = positions("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = 7, normalisation = "none"), "'level' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "none"), positions_T_all_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "sum"), positions_T_all_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "size class"), positions_T_all_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "none"), positions_T_rows_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "sum"), positions_T_rows_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "size class"), positions_T_rows_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "none"), positions_T_columns_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "sum"), positions_T_columns_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "size class"), positions_T_columns_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "none"), positions_F_all_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "sum"), positions_F_all_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "size class"), positions_F_all_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "none"), positions_F_rows_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "sum"), positions_F_rows_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "size class"), positions_F_rows_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "none"), positions_F_columns_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "sum"), positions_F_columns_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "size class"), positions_F_columns_sc)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, level = "all", normalisation = "none") 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length 0")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(level) != "character") {
          stop("'level' must be of class 'character'")
      }
      if (!level %in% c("rows", "columns", "all")) {
          stop("'level' must equal 'rows', 'columns' or 'all'")
      }
      if (class(normalisation) != "character") {
          stop("'normalisation' must be of class 'character'")
      }
      if (!normalisation %in% c("none", "sum", "size class")) {
          stop("'normalisation' must equal 'none', 'sum' or 'size class'")
      }
      M[M > 0] <- 1
      if (is.null(rownames(M))) {
          rownames(M) <- paste0("R", 1:nrow(M))
          warning("M had no row names and so has been assigned default row names")
      }
      if (is.null(colnames(M))) {
          colnames(M) <- paste0("C", 1:ncol(M))
          warning("M had no column names and so has been assigned default column names")
      }
      rn <- rownames(M)
      cn <- colnames(M)
      dimnames(M) <- NULL
      Z <- nrow(M)
      P <- ncol(M)
      jZ <- matrix(rep(1, Z))
      jP <- matrix(rep(1, P))
      J <- matrix(rep(1, Z * P), nrow = Z, ncol = P)
      JP <- matrix(rep(1, P * P), nrow = P, ncol = P)
      JZ <- matrix(rep(1, Z * Z), nrow = Z, ncol = Z)
      if (six_node == TRUE) {
          JP3 <- array(rep(1, P * P * P), c(P, P, P))
          JZ3 <- array(rep(1, Z * Z * Z), c(Z, Z, Z))
          KP3 <- JP3
          for (i in 1:P) {
              for (j in 1:P) {
                  KP3[i, j, j] <- 0
                  KP3[j, i, j] <- 0
                  KP3[j, j, i] <- 0
              }
          }
          KZ3 <- JZ3
          for (i in 1:Z) {
              for (j in 1:Z) {
                  KZ3[i, j, j] <- 0
                  KZ3[j, i, j] <- 0
                  KZ3[j, j, i] <- 0
              }
          }
      }
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      dZ <- M %*% jP
      dP <- MT %*% jZ
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      if (six_node == TRUE) {
          AZ <- maketensor(M, M)
          BZ <- maketensor(M, N)
          CZ <- maketensor(N, M)
          DZ <- maketensor(N, N)
          AP <- maketensor(MT, MT)
          BP <- maketensor(MT, NT)
          CP <- maketensor(NT, MT)
          DP <- maketensor(NT, NT)
          MTA <- multtensor(MT, AZ)
          MTB <- multtensor(MT, BZ)
          MTC <- multtensor(MT, CZ)
          MTD <- multtensor(MT, DZ)
          MA <- multtensor(M, AP)
          MB <- multtensor(M, BP)
          MC <- multtensor(M, CP)
          MD <- multtensor(M, DP)
          NTA <- multtensor(NT, AZ)
          NTB <- multtensor(NT, BZ)
          NTC <- multtensor(NT, CZ)
          Na <- multtensor(N, AP)
          NB <- multtensor(N, BP)
          NC <- multtensor(N, CP)
      }
      if (six_node == FALSE) {
          pos_row <- matrix(0, ncol = 46, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:46)))
          pos_col <- matrix(0, ncol = 46, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:46)))
      }
      else {
          pos_row <- matrix(0, ncol = 148, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:148)))
          pos_col <- matrix(0, ncol = 148, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:148)))
      }
      if (six_node == FALSE) {
          for (i in 1:46) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      else {
          for (i in 1:148) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, JP3 = JP3, JZ3 = JZ3, KP3 = KP3, 
                  KZ3 = KZ3, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R, 
                  MTA = MTA, MTB = MTB, MTC = MTC, MTD = MTD, MA = MA, 
                  MB = MB, MC = MC, MD = MD, NTA = NTA, NTB = NTB, 
                  NTC = NTC, Na = Na, NB = NB, NC = NC)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      if (normalisation != "none") {
          pos_row <- normalise_positions(pc = pos_row, type = normalisation)
          pos_col <- normalise_positions(pc = pos_col, type = normalisation)
      }
      if (level == "all") {
          out <- rbind(pos_row, pos_col)
          out <- as.data.frame(out)
          return(out)
      }
      else if (level == "rows") {
          pos_row <- as.data.frame(pos_row)
          return(pos_row)
      }
      else if (level == "columns") {
          pos_col <- as.data.frame(pos_col)
          return(pos_col)
      }
  }
  <bytecode: 0x45c1628>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function positions in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 8. Failure: positions behaves as expected (@test_positions.R#5)  ------------
  `positions(matrix(1, 3, 3), six_node = TRUE, level = 7, normalisation = "none")` threw an error with unexpected message.
  Expected match: "'level' must be of class 'character'"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::positions(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  positions(matrix(1, 3, 3), six_node = TRUE, level = "wrong", 
      normalisation = "none")
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: positions(matrix(1, 3, 3), six_node = TRUE, level = "wrong", 
      normalisation = "none")
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_positions.R#6: expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
      level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
  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_positions.R#1: test_that("positions behaves as expected", {
      expect_error(object = positions("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = 7, normalisation = "none"), "'level' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "none"), positions_T_all_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "sum"), positions_T_all_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "size class"), positions_T_all_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "none"), positions_T_rows_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "sum"), positions_T_rows_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "size class"), positions_T_rows_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "none"), positions_T_columns_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "sum"), positions_T_columns_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "size class"), positions_T_columns_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "none"), positions_F_all_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "sum"), positions_F_all_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "size class"), positions_F_all_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "none"), positions_F_rows_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "sum"), positions_F_rows_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "size class"), positions_F_rows_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "none"), positions_F_columns_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "sum"), positions_F_columns_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "size class"), positions_F_columns_sc)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, level = "all", normalisation = "none") 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length 0")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(level) != "character") {
          stop("'level' must be of class 'character'")
      }
      if (!level %in% c("rows", "columns", "all")) {
          stop("'level' must equal 'rows', 'columns' or 'all'")
      }
      if (class(normalisation) != "character") {
          stop("'normalisation' must be of class 'character'")
      }
      if (!normalisation %in% c("none", "sum", "size class")) {
          stop("'normalisation' must equal 'none', 'sum' or 'size class'")
      }
      M[M > 0] <- 1
      if (is.null(rownames(M))) {
          rownames(M) <- paste0("R", 1:nrow(M))
          warning("M had no row names and so has been assigned default row names")
      }
      if (is.null(colnames(M))) {
          colnames(M) <- paste0("C", 1:ncol(M))
          warning("M had no column names and so has been assigned default column names")
      }
      rn <- rownames(M)
      cn <- colnames(M)
      dimnames(M) <- NULL
      Z <- nrow(M)
      P <- ncol(M)
      jZ <- matrix(rep(1, Z))
      jP <- matrix(rep(1, P))
      J <- matrix(rep(1, Z * P), nrow = Z, ncol = P)
      JP <- matrix(rep(1, P * P), nrow = P, ncol = P)
      JZ <- matrix(rep(1, Z * Z), nrow = Z, ncol = Z)
      if (six_node == TRUE) {
          JP3 <- array(rep(1, P * P * P), c(P, P, P))
          JZ3 <- array(rep(1, Z * Z * Z), c(Z, Z, Z))
          KP3 <- JP3
          for (i in 1:P) {
              for (j in 1:P) {
                  KP3[i, j, j] <- 0
                  KP3[j, i, j] <- 0
                  KP3[j, j, i] <- 0
              }
          }
          KZ3 <- JZ3
          for (i in 1:Z) {
              for (j in 1:Z) {
                  KZ3[i, j, j] <- 0
                  KZ3[j, i, j] <- 0
                  KZ3[j, j, i] <- 0
              }
          }
      }
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      dZ <- M %*% jP
      dP <- MT %*% jZ
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      if (six_node == TRUE) {
          AZ <- maketensor(M, M)
          BZ <- maketensor(M, N)
          CZ <- maketensor(N, M)
          DZ <- maketensor(N, N)
          AP <- maketensor(MT, MT)
          BP <- maketensor(MT, NT)
          CP <- maketensor(NT, MT)
          DP <- maketensor(NT, NT)
          MTA <- multtensor(MT, AZ)
          MTB <- multtensor(MT, BZ)
          MTC <- multtensor(MT, CZ)
          MTD <- multtensor(MT, DZ)
          MA <- multtensor(M, AP)
          MB <- multtensor(M, BP)
          MC <- multtensor(M, CP)
          MD <- multtensor(M, DP)
          NTA <- multtensor(NT, AZ)
          NTB <- multtensor(NT, BZ)
          NTC <- multtensor(NT, CZ)
          Na <- multtensor(N, AP)
          NB <- multtensor(N, BP)
          NC <- multtensor(N, CP)
      }
      if (six_node == FALSE) {
          pos_row <- matrix(0, ncol = 46, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:46)))
          pos_col <- matrix(0, ncol = 46, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:46)))
      }
      else {
          pos_row <- matrix(0, ncol = 148, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:148)))
          pos_col <- matrix(0, ncol = 148, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:148)))
      }
      if (six_node == FALSE) {
          for (i in 1:46) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      else {
          for (i in 1:148) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, JP3 = JP3, JZ3 = JZ3, KP3 = KP3, 
                  KZ3 = KZ3, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R, 
                  MTA = MTA, MTB = MTB, MTC = MTC, MTD = MTD, MA = MA, 
                  MB = MB, MC = MC, MD = MD, NTA = NTA, NTB = NTB, 
                  NTC = NTC, Na = Na, NB = NB, NC = NC)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      if (normalisation != "none") {
          pos_row <- normalise_positions(pc = pos_row, type = normalisation)
          pos_col <- normalise_positions(pc = pos_col, type = normalisation)
      }
      if (level == "all") {
          out <- rbind(pos_row, pos_col)
          out <- as.data.frame(out)
          return(out)
      }
      else if (level == "rows") {
          pos_row <- as.data.frame(pos_row)
          return(pos_row)
      }
      else if (level == "columns") {
          pos_col <- as.data.frame(pos_col)
          return(pos_col)
      }
  }
  <bytecode: 0x45c1628>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function positions in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 9. Failure: positions behaves as expected (@test_positions.R#6)  ------------
  `positions(...)` threw an error with unexpected message.
  Expected match: "'level' must equal 'rows', 'columns' or 'all'"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::positions(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  positions(matrix(1, 3, 3), six_node = TRUE, level = "all", normalisation = 7)
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: positions(matrix(1, 3, 3), six_node = TRUE, level = "all", normalisation = 7)
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_positions.R#7: expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
      level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
  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_positions.R#1: test_that("positions behaves as expected", {
      expect_error(object = positions("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = 7, normalisation = "none"), "'level' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "none"), positions_T_all_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "sum"), positions_T_all_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "size class"), positions_T_all_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "none"), positions_T_rows_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "sum"), positions_T_rows_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "size class"), positions_T_rows_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "none"), positions_T_columns_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "sum"), positions_T_columns_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "size class"), positions_T_columns_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "none"), positions_F_all_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "sum"), positions_F_all_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "size class"), positions_F_all_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "none"), positions_F_rows_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "sum"), positions_F_rows_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "size class"), positions_F_rows_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "none"), positions_F_columns_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "sum"), positions_F_columns_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "size class"), positions_F_columns_sc)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, level = "all", normalisation = "none") 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length 0")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(level) != "character") {
          stop("'level' must be of class 'character'")
      }
      if (!level %in% c("rows", "columns", "all")) {
          stop("'level' must equal 'rows', 'columns' or 'all'")
      }
      if (class(normalisation) != "character") {
          stop("'normalisation' must be of class 'character'")
      }
      if (!normalisation %in% c("none", "sum", "size class")) {
          stop("'normalisation' must equal 'none', 'sum' or 'size class'")
      }
      M[M > 0] <- 1
      if (is.null(rownames(M))) {
          rownames(M) <- paste0("R", 1:nrow(M))
          warning("M had no row names and so has been assigned default row names")
      }
      if (is.null(colnames(M))) {
          colnames(M) <- paste0("C", 1:ncol(M))
          warning("M had no column names and so has been assigned default column names")
      }
      rn <- rownames(M)
      cn <- colnames(M)
      dimnames(M) <- NULL
      Z <- nrow(M)
      P <- ncol(M)
      jZ <- matrix(rep(1, Z))
      jP <- matrix(rep(1, P))
      J <- matrix(rep(1, Z * P), nrow = Z, ncol = P)
      JP <- matrix(rep(1, P * P), nrow = P, ncol = P)
      JZ <- matrix(rep(1, Z * Z), nrow = Z, ncol = Z)
      if (six_node == TRUE) {
          JP3 <- array(rep(1, P * P * P), c(P, P, P))
          JZ3 <- array(rep(1, Z * Z * Z), c(Z, Z, Z))
          KP3 <- JP3
          for (i in 1:P) {
              for (j in 1:P) {
                  KP3[i, j, j] <- 0
                  KP3[j, i, j] <- 0
                  KP3[j, j, i] <- 0
              }
          }
          KZ3 <- JZ3
          for (i in 1:Z) {
              for (j in 1:Z) {
                  KZ3[i, j, j] <- 0
                  KZ3[j, i, j] <- 0
                  KZ3[j, j, i] <- 0
              }
          }
      }
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      dZ <- M %*% jP
      dP <- MT %*% jZ
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      if (six_node == TRUE) {
          AZ <- maketensor(M, M)
          BZ <- maketensor(M, N)
          CZ <- maketensor(N, M)
          DZ <- maketensor(N, N)
          AP <- maketensor(MT, MT)
          BP <- maketensor(MT, NT)
          CP <- maketensor(NT, MT)
          DP <- maketensor(NT, NT)
          MTA <- multtensor(MT, AZ)
          MTB <- multtensor(MT, BZ)
          MTC <- multtensor(MT, CZ)
          MTD <- multtensor(MT, DZ)
          MA <- multtensor(M, AP)
          MB <- multtensor(M, BP)
          MC <- multtensor(M, CP)
          MD <- multtensor(M, DP)
          NTA <- multtensor(NT, AZ)
          NTB <- multtensor(NT, BZ)
          NTC <- multtensor(NT, CZ)
          Na <- multtensor(N, AP)
          NB <- multtensor(N, BP)
          NC <- multtensor(N, CP)
      }
      if (six_node == FALSE) {
          pos_row <- matrix(0, ncol = 46, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:46)))
          pos_col <- matrix(0, ncol = 46, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:46)))
      }
      else {
          pos_row <- matrix(0, ncol = 148, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:148)))
          pos_col <- matrix(0, ncol = 148, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:148)))
      }
      if (six_node == FALSE) {
          for (i in 1:46) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      else {
          for (i in 1:148) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, JP3 = JP3, JZ3 = JZ3, KP3 = KP3, 
                  KZ3 = KZ3, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R, 
                  MTA = MTA, MTB = MTB, MTC = MTC, MTD = MTD, MA = MA, 
                  MB = MB, MC = MC, MD = MD, NTA = NTA, NTB = NTB, 
                  NTC = NTC, Na = Na, NB = NB, NC = NC)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      if (normalisation != "none") {
          pos_row <- normalise_positions(pc = pos_row, type = normalisation)
          pos_col <- normalise_positions(pc = pos_col, type = normalisation)
      }
      if (level == "all") {
          out <- rbind(pos_row, pos_col)
          out <- as.data.frame(out)
          return(out)
      }
      else if (level == "rows") {
          pos_row <- as.data.frame(pos_row)
          return(pos_row)
      }
      else if (level == "columns") {
          pos_col <- as.data.frame(pos_col)
          return(pos_col)
      }
  }
  <bytecode: 0x45c1628>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function positions in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 10. Failure: positions behaves as expected (@test_positions.R#7)  -----------
  `positions(matrix(1, 3, 3), six_node = TRUE, level = "all", normalisation = 7)` threw an error with unexpected message.
  Expected match: "'normalisation' must be of class 'character'"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::positions(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  positions(matrix(1, 3, 3), six_node = TRUE, level = "all", normalisation = "wrong")
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: positions(matrix(1, 3, 3), six_node = TRUE, level = "all", normalisation = "wrong")
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withCallingHandlers({
      code
      NULL
  }, error = function(cnd) {
      if (can_entrace(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_positions.R#8: expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
      level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
  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_positions.R#1: test_that("positions behaves as expected", {
      expect_error(object = positions("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = 7, normalisation = "none"), "'level' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "none"), positions_T_all_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "sum"), positions_T_all_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "size class"), positions_T_all_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "none"), positions_T_rows_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "sum"), positions_T_rows_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "size class"), positions_T_rows_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "none"), positions_T_columns_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "sum"), positions_T_columns_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "size class"), positions_T_columns_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "none"), positions_F_all_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "sum"), positions_F_all_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "size class"), positions_F_all_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "none"), positions_F_rows_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "sum"), positions_F_rows_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "size class"), positions_F_rows_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "none"), positions_F_columns_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "sum"), positions_F_columns_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "size class"), positions_F_columns_sc)
  })
  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("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, level = "all", normalisation = "none") 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length 0")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(level) != "character") {
          stop("'level' must be of class 'character'")
      }
      if (!level %in% c("rows", "columns", "all")) {
          stop("'level' must equal 'rows', 'columns' or 'all'")
      }
      if (class(normalisation) != "character") {
          stop("'normalisation' must be of class 'character'")
      }
      if (!normalisation %in% c("none", "sum", "size class")) {
          stop("'normalisation' must equal 'none', 'sum' or 'size class'")
      }
      M[M > 0] <- 1
      if (is.null(rownames(M))) {
          rownames(M) <- paste0("R", 1:nrow(M))
          warning("M had no row names and so has been assigned default row names")
      }
      if (is.null(colnames(M))) {
          colnames(M) <- paste0("C", 1:ncol(M))
          warning("M had no column names and so has been assigned default column names")
      }
      rn <- rownames(M)
      cn <- colnames(M)
      dimnames(M) <- NULL
      Z <- nrow(M)
      P <- ncol(M)
      jZ <- matrix(rep(1, Z))
      jP <- matrix(rep(1, P))
      J <- matrix(rep(1, Z * P), nrow = Z, ncol = P)
      JP <- matrix(rep(1, P * P), nrow = P, ncol = P)
      JZ <- matrix(rep(1, Z * Z), nrow = Z, ncol = Z)
      if (six_node == TRUE) {
          JP3 <- array(rep(1, P * P * P), c(P, P, P))
          JZ3 <- array(rep(1, Z * Z * Z), c(Z, Z, Z))
          KP3 <- JP3
          for (i in 1:P) {
              for (j in 1:P) {
                  KP3[i, j, j] <- 0
                  KP3[j, i, j] <- 0
                  KP3[j, j, i] <- 0
              }
          }
          KZ3 <- JZ3
          for (i in 1:Z) {
              for (j in 1:Z) {
                  KZ3[i, j, j] <- 0
                  KZ3[j, i, j] <- 0
                  KZ3[j, j, i] <- 0
              }
          }
      }
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      dZ <- M %*% jP
      dP <- MT %*% jZ
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      if (six_node == TRUE) {
          AZ <- maketensor(M, M)
          BZ <- maketensor(M, N)
          CZ <- maketensor(N, M)
          DZ <- maketensor(N, N)
          AP <- maketensor(MT, MT)
          BP <- maketensor(MT, NT)
          CP <- maketensor(NT, MT)
          DP <- maketensor(NT, NT)
          MTA <- multtensor(MT, AZ)
          MTB <- multtensor(MT, BZ)
          MTC <- multtensor(MT, CZ)
          MTD <- multtensor(MT, DZ)
          MA <- multtensor(M, AP)
          MB <- multtensor(M, BP)
          MC <- multtensor(M, CP)
          MD <- multtensor(M, DP)
          NTA <- multtensor(NT, AZ)
          NTB <- multtensor(NT, BZ)
          NTC <- multtensor(NT, CZ)
          Na <- multtensor(N, AP)
          NB <- multtensor(N, BP)
          NC <- multtensor(N, CP)
      }
      if (six_node == FALSE) {
          pos_row <- matrix(0, ncol = 46, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:46)))
          pos_col <- matrix(0, ncol = 46, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:46)))
      }
      else {
          pos_row <- matrix(0, ncol = 148, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:148)))
          pos_col <- matrix(0, ncol = 148, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:148)))
      }
      if (six_node == FALSE) {
          for (i in 1:46) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      else {
          for (i in 1:148) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, JP3 = JP3, JZ3 = JZ3, KP3 = KP3, 
                  KZ3 = KZ3, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R, 
                  MTA = MTA, MTB = MTB, MTC = MTC, MTD = MTD, MA = MA, 
                  MB = MB, MC = MC, MD = MD, NTA = NTA, NTB = NTB, 
                  NTC = NTC, Na = Na, NB = NB, NC = NC)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      if (normalisation != "none") {
          pos_row <- normalise_positions(pc = pos_row, type = normalisation)
          pos_col <- normalise_positions(pc = pos_col, type = normalisation)
      }
      if (level == "all") {
          out <- rbind(pos_row, pos_col)
          out <- as.data.frame(out)
          return(out)
      }
      else if (level == "rows") {
          pos_row <- as.data.frame(pos_row)
          return(pos_row)
      }
      else if (level == "columns") {
          pos_col <- as.data.frame(pos_col)
          return(pos_col)
      }
  }
  <bytecode: 0x45c1628>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function positions in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 11. Failure: positions behaves as expected (@test_positions.R#8)  -----------
  `positions(matrix(1, 3, 3), six_node = TRUE, level = "all", normalisation = "wrong")` threw an error with unexpected message.
  Expected match: "'normalisation' must equal 'none', 'sum' or 'size class'"
  Actual message: "the condition has length > 1"
  Backtrace:
   1. testthat::expect_error(...)
   6. bmotif::positions(...)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  bmotif
   --- call from context --- 
  positions(M = mat, six_node = TRUE, level = "all", normalisation = "none")
   --- call from argument --- 
  if (class(M) != "matrix") {
      stop("'M' must be an object of class 'matrix'")
  }
   --- R stacktrace ---
  where 1: positions(M = mat, six_node = TRUE, level = "all", normalisation = "none")
  where 2: eval_bare(expr, quo_get_env(quo))
  where 3: quasi_label(enquo(object), label, arg = "object")
  where 4 at testthat/test_positions.R#10: expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
      normalisation = "none"), positions_T_all_none)
  where 5: eval(code, test_env)
  where 6: eval(code, test_env)
  where 7: 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 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 10: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 11: doTryCatch(return(expr), name, parentenv, handler)
  where 12: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 13: tryCatchList(expr, classes, parentenv, handlers)
  where 14: 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 15: test_code(desc, code, env = parent.frame())
  where 16 at testthat/test_positions.R#1: test_that("positions behaves as expected", {
      expect_error(object = positions("a"), "'M' must be an object of class 'matrix'")
      expect_error(object = positions(matrix("a", 3, 3)), "Elements of 'M' must be numeric")
      expect_error(object = positions(matrix(-1, 3, 3)), "Elements of 'M' must be greater than or equal to zero")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = 7, normalisation = "none"), "'level' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "wrong", normalisation = "none"), "'level' must equal 'rows', 'columns' or 'all'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = 7), "'normalisation' must be of class 'character'")
      expect_error(object = positions(matrix(1, 3, 3), six_node = TRUE, 
          level = "all", normalisation = "wrong"), "'normalisation' must equal 'none', 'sum' or 'size class'")
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "none"), positions_T_all_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "sum"), positions_T_all_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "all", 
          normalisation = "size class"), positions_T_all_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "none"), positions_T_rows_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "sum"), positions_T_rows_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "rows", 
          normalisation = "size class"), positions_T_rows_sc)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "none"), positions_T_columns_none)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "sum"), positions_T_columns_sum)
      expect_equal(positions(M = mat, six_node = TRUE, level = "columns", 
          normalisation = "size class"), positions_T_columns_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "none"), positions_F_all_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "sum"), positions_F_all_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "all", 
          normalisation = "size class"), positions_F_all_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "none"), positions_F_rows_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "sum"), positions_F_rows_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "rows", 
          normalisation = "size class"), positions_F_rows_sc)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "none"), positions_F_columns_none)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "sum"), positions_F_columns_sum)
      expect_equal(positions(M = mat, six_node = FALSE, level = "columns", 
          normalisation = "size class"), positions_F_columns_sc)
  })
  where 17: eval(code, test_env)
  where 18: eval(code, test_env)
  where 19: 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 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 22: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 23: doTryCatch(return(expr), name, parentenv, handler)
  where 24: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 25: tryCatchList(expr, classes, parentenv, handlers)
  where 26: 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 27: test_code(NULL, exprs, env)
  where 28: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 29: force(code)
  where 30: doWithOneRestart(return(expr), restart)
  where 31: withOneRestart(expr, restarts[[1L]])
  where 32: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 33: 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 34: FUN(X[[i]], ...)
  where 35: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 36: force(code)
  where 37: doWithOneRestart(return(expr), restart)
  where 38: withOneRestart(expr, restarts[[1L]])
  where 39: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 40: 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 41: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 42: 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 43: 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 44: test_check("bmotif")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (M, six_node, level = "all", normalisation = "none") 
  {
      if (class(M) != "matrix") {
          stop("'M' must be an object of class 'matrix'")
      }
      if (!all(apply(M, 1:2, is.numeric))) {
          stop("Elements of 'M' must be numeric")
      }
      if (!all(apply(M, 1:2, function(x) length(x) > 0))) {
          stop("Elements of 'M' cannot have length 0")
      }
      if (!all(apply(M, 1:2, function(x) x >= 0))) {
          stop("Elements of 'M' must be greater than or equal to zero")
      }
      if (class(level) != "character") {
          stop("'level' must be of class 'character'")
      }
      if (!level %in% c("rows", "columns", "all")) {
          stop("'level' must equal 'rows', 'columns' or 'all'")
      }
      if (class(normalisation) != "character") {
          stop("'normalisation' must be of class 'character'")
      }
      if (!normalisation %in% c("none", "sum", "size class")) {
          stop("'normalisation' must equal 'none', 'sum' or 'size class'")
      }
      M[M > 0] <- 1
      if (is.null(rownames(M))) {
          rownames(M) <- paste0("R", 1:nrow(M))
          warning("M had no row names and so has been assigned default row names")
      }
      if (is.null(colnames(M))) {
          colnames(M) <- paste0("C", 1:ncol(M))
          warning("M had no column names and so has been assigned default column names")
      }
      rn <- rownames(M)
      cn <- colnames(M)
      dimnames(M) <- NULL
      Z <- nrow(M)
      P <- ncol(M)
      jZ <- matrix(rep(1, Z))
      jP <- matrix(rep(1, P))
      J <- matrix(rep(1, Z * P), nrow = Z, ncol = P)
      JP <- matrix(rep(1, P * P), nrow = P, ncol = P)
      JZ <- matrix(rep(1, Z * Z), nrow = Z, ncol = Z)
      if (six_node == TRUE) {
          JP3 <- array(rep(1, P * P * P), c(P, P, P))
          JZ3 <- array(rep(1, Z * Z * Z), c(Z, Z, Z))
          KP3 <- JP3
          for (i in 1:P) {
              for (j in 1:P) {
                  KP3[i, j, j] <- 0
                  KP3[j, i, j] <- 0
                  KP3[j, j, i] <- 0
              }
          }
          KZ3 <- JZ3
          for (i in 1:Z) {
              for (j in 1:Z) {
                  KZ3[i, j, j] <- 0
                  KZ3[j, i, j] <- 0
                  KZ3[j, j, i] <- 0
              }
          }
      }
      MT <- t(M)
      N <- J - M
      NT <- t(N)
      dZ <- M %*% jP
      dP <- MT %*% jZ
      Z <- M %*% MT
      Y <- M %*% NT
      X <- N %*% MT
      P <- MT %*% M
      Q <- MT %*% N
      R <- NT %*% M
      if (six_node == TRUE) {
          AZ <- maketensor(M, M)
          BZ <- maketensor(M, N)
          CZ <- maketensor(N, M)
          DZ <- maketensor(N, N)
          AP <- maketensor(MT, MT)
          BP <- maketensor(MT, NT)
          CP <- maketensor(NT, MT)
          DP <- maketensor(NT, NT)
          MTA <- multtensor(MT, AZ)
          MTB <- multtensor(MT, BZ)
          MTC <- multtensor(MT, CZ)
          MTD <- multtensor(MT, DZ)
          MA <- multtensor(M, AP)
          MB <- multtensor(M, BP)
          MC <- multtensor(M, CP)
          MD <- multtensor(M, DP)
          NTA <- multtensor(NT, AZ)
          NTB <- multtensor(NT, BZ)
          NTC <- multtensor(NT, CZ)
          Na <- multtensor(N, AP)
          NB <- multtensor(N, BP)
          NC <- multtensor(N, CP)
      }
      if (six_node == FALSE) {
          pos_row <- matrix(0, ncol = 46, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:46)))
          pos_col <- matrix(0, ncol = 46, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:46)))
      }
      else {
          pos_row <- matrix(0, ncol = 148, nrow = nrow(M), dimnames = list(rn, 
              paste0("p", 1:148)))
          pos_col <- matrix(0, ncol = 148, nrow = ncol(M), dimnames = list(cn, 
              paste0("p", 1:148)))
      }
      if (six_node == FALSE) {
          for (i in 1:46) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      else {
          for (i in 1:148) {
              rc <- rowcolumn(i)
              f <- countposition(M = M, p = i, jZ = jZ, jP = jP, 
                  JP = JP, JZ = JZ, JP3 = JP3, JZ3 = JZ3, KP3 = KP3, 
                  KZ3 = KZ3, MT = MT, N = N, NT = NT, dZ = dZ, 
                  dP = dP, Z = Z, Y = Y, X = X, P = P, Q = Q, R = R, 
                  MTA = MTA, MTB = MTB, MTC = MTC, MTD = MTD, MA = MA, 
                  MB = MB, MC = MC, MD = MD, NTA = NTA, NTB = NTB, 
                  NTC = NTC, Na = Na, NB = NB, NC = NC)
              if (rc == "row") {
                  pos_row[, i] <- f
              }
              else {
                  pos_col[, i] <- f
              }
          }
      }
      if (normalisation != "none") {
          pos_row <- normalise_positions(pc = pos_row, type = normalisation)
          pos_col <- normalise_positions(pc = pos_col, type = normalisation)
      }
      if (level == "all") {
          out <- rbind(pos_row, pos_col)
          out <- as.data.frame(out)
          return(out)
      }
      else if (level == "rows") {
          pos_row <- as.data.frame(pos_row)
          return(pos_row)
      }
      else if (level == "columns") {
          pos_col <- as.data.frame(pos_col)
          return(pos_col)
      }
  }
  <bytecode: 0x45c1628>
  <environment: namespace:bmotif>
   --- function search by body ---
  Function positions in namespace bmotif has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 12. Error: positions behaves as expected (@test_positions.R#10)  ------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_equal(...)
   4. bmotif::positions(M = mat, six_node = TRUE, level = "all", normalisation = "none")
  
  == testthat results  ===========================================================
  [ OK: 2 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 12 ]
  1. Failure: mcount behaves as expected (@test_mcount.R#3) 
  2. Failure: mcount behaves as expected (@test_mcount.R#4) 
  3. Failure: mcount behaves as expected (@test_mcount.R#5) 
  4. Failure: mcount behaves as expected (@test_mcount.R#6) 
  5. Error: mcount behaves as expected (@test_mcount.R#8) 
  6. Failure: positions behaves as expected (@test_positions.R#3) 
  7. Failure: positions behaves as expected (@test_positions.R#4) 
  8. Failure: positions behaves as expected (@test_positions.R#5) 
  9. Failure: positions behaves as expected (@test_positions.R#6) 
  1. ...
  
  Error: testthat unit tests failed
  Execution halted