Running ‘testthat.R’ [3s/5s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(matsbyname)
  > 
  > test_check("matsbyname")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  matsbyname
   --- call from context --- 
  (function (a, margin) 
  {
      if (class(a) == "numeric" & length(a) == 1) {
          return(1)
      }
      if (!length(margin) %in% c(1, 2)) {
          stop("margin should have length 1 or 2 in fractionize_byname")
      }
      if (length(margin) == 2 && all(margin %in% c(1, 2))) {
          stopifnot(nrow(a) == ncol(a))
          return(diag(nrow(a)) %>% setrownames_byname(rownames(a)) %>% 
              setcolnames_byname(colnames(a)) %>% setrowtype(rowtype(a)) %>% 
              setcoltype(coltype(a)))
      }
      if (length(margin) != 1 || !(margin %in% c(1, 2))) {
          stop(paste("Unknown margin", margin, "in identize_byname. margin should be 1, 2, or c(1,2)."))
      }
      if (margin == 1) {
          return(matrix(rep_len(1, nrow(a)), nrow = nrow(a), ncol = 1) %>% 
              setrownames_byname(rownames(a)) %>% setcolnames_byname(coltype(a)) %>% 
              setrowtype(rowtype(a)) %>% setcoltype(coltype(a)))
      }
      if (margin == 2) {
          return(matrix(rep_len(1, ncol(a)), nrow = 1, ncol = ncol(a)) %>% 
              setrownames_byname(rowtype(a)) %>% setcolnames_byname(colnames(a)) %>% 
              setrowtype(rowtype(a)) %>% setcoltype(coltype(a)))
      }
  })(c(11, 21, 12, 22), margin = c(1, 2))
   --- call from argument --- 
  if (class(a) == "numeric" & length(a) == 1) {
      return(1)
  }
   --- R stacktrace ---
  where 1: (function (a, margin) 
  {
      if (class(a) == "numeric" & length(a) == 1) {
          return(1)
      }
      if (!length(margin) %in% c(1, 2)) {
          stop("margin should have length 1 or 2 in fractionize_byname")
      }
      if (length(margin) == 2 && all(margin %in% c(1, 2))) {
          stopifnot(nrow(a) == ncol(a))
          return(diag(nrow(a)) %>% setrownames_byname(rownames(a)) %>% 
              setcolnames_byname(colnames(a)) %>% setrowtype(rowtype(a)) %>% 
              setcoltype(coltype(a)))
      }
      if (length(margin) != 1 || !(margin %in% c(1, 2))) {
          stop(paste("Unknown margin", margin, "in identize_byname. margin should be 1, 2, or c(1,2)."))
      }
      if (margin == 1) {
          return(matrix(rep_len(1, nrow(a)), nrow = nrow(a), ncol = 1) %>% 
              setrownames_byname(rownames(a)) %>% setcolnames_byname(coltype(a)) %>% 
              setrowtype(rowtype(a)) %>% setcoltype(coltype(a)))
      }
      if (margin == 2) {
          return(matrix(rep_len(1, ncol(a)), nrow = 1, ncol = ncol(a)) %>% 
              setrownames_byname(rowtype(a)) %>% setcolnames_byname(colnames(a)) %>% 
              setrowtype(rowtype(a)) %>% setcoltype(coltype(a)))
      }
  })(c(11, 21, 12, 22), margin = c(1, 2))
  where 2: do.call(FUN, c(list(a), .FUNdots))
  where 3: unaryapply_byname(identize_func, a = a, .FUNdots = list(margin = margin), 
      rowcoltypes = "none")
  where 4: identize_byname(M)
  where 5: eval(lhs, parent, parent)
  where 6: eval(lhs, parent, parent)
  where 7 at testthat/test_Binary.R#262: identize_byname(M) %>% setrownames_byname(c("A", "B")) %>% setcolnames_byname(c("E", 
      "F"))
  where 8: eval(code, test_env)
  where 9: eval(code, test_env)
  where 10: 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 11: doTryCatch(return(expr), name, parentenv, handler)
  where 12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 13: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 14: doTryCatch(return(expr), name, parentenv, handler)
  where 15: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 16: tryCatchList(expr, classes, parentenv, handlers)
  where 17: 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 18: test_code(desc, code, env = parent.frame())
  where 19 at testthat/test_Binary.R#238: test_that("matrixproduct_byname works as expected", {
      V <- matrix(1:6, ncol = 3, dimnames = list(c("i1", "i2"), 
          c("p1", "p2", "p3"))) %>% setrowtype("Industries") %>% 
          setcoltype("Products")
      Y <- matrix(1:4, ncol = 2, dimnames = list(c("p2", "p1"), 
          c("s2", "s1"))) %>% setrowtype("Products") %>% setcoltype("Sectors")
      Z <- matrix(11:14, ncol = 2, dimnames = list(c("s2", "s1"), 
          c("c1", "c2"))) %>% setrowtype("Sectors") %>% setcoltype("Columns")
      VY <- matrix(c(13, 5, 20, 8), nrow = 2, ncol = 2, byrow = TRUE, 
          dimnames = list(c("i1", "i2"), c("s1", "s2"))) %>% setrowtype("Industries") %>% 
          setcoltype("Sectors")
      VYZ <- matrixproduct_byname(VY, Z)
      expect_error(V %*% Y, "non-conformable arguments")
      expect_equal(matrixproduct_byname(V, Y), VY)
      expect_equal(matrixproduct_byname(V, Y, Z), VYZ)
      M <- matrix(c(11, 12, 21, 22), nrow = 2, ncol = 2, byrow = TRUE) %>% 
          setrownames_byname(c("C", "D")) %>% setcolnames_byname(c("A", 
          "B"))
      I <- identize_byname(M) %>% setrownames_byname(c("A", "B")) %>% 
          setcolnames_byname(c("E", "F"))
      expect_equal(matrixproduct_byname(M, I), M %>% setcolnames_byname(colnames(I)))
      I2 <- I %>% setrownames_byname(c("G", "H"))
      expect_equal(matrixproduct_byname(M, I2), matrix(c(0, 0, 
          0, 0), nrow = 2, ncol = 2, byrow = TRUE) %>% setrownames_byname(c("C", 
          "D")) %>% setcolnames_byname(c("E", "F")))
      expect_equal(M %*% I2, M %>% setrownames_byname(c("C", "D")) %>% 
          setcolnames_byname(c("E", "F")))
      expect_equal(matrixproduct_byname(list(V, V), list(Y, Y)), 
          list(VY, VY))
      DF <- data.frame(V = I(list()), Y = I(list()), Z = I(list()))
      DF[[1, "V"]] <- V
      DF[[2, "V"]] <- V
      DF[[1, "Y"]] <- Y
      DF[[2, "Y"]] <- Y
      DF[[1, "Z"]] <- Z
      DF[[2, "Z"]] <- Z
      expect_equal(matrixproduct_byname(DF$V, DF$Y), list(VY, VY))
      expect_equal(matrixproduct_byname(DF$V, DF$Y, DF$Z), list(VYZ, 
          VYZ))
      DF_expected <- data.frame(V = I(list()), Y = I(list()), Z = I(list()), 
          matprods = I(list()), VYZ = I(list()))
      DF_expected[[1, "V"]] <- V
      DF_expected[[2, "V"]] <- V
      DF_expected[[1, "Y"]] <- Y
      DF_expected[[2, "Y"]] <- Y
      DF_expected[[1, "Z"]] <- Z
      DF_expected[[2, "Z"]] <- Z
      DF_expected[[1, "matprods"]] <- VY
      DF_expected[[2, "matprods"]] <- VY
      DF_expected[[1, "VYZ"]] <- VYZ
      DF_expected[[2, "VYZ"]] <- VYZ
      attr(DF_expected$matprods, which = "class") <- NULL
      attr(DF_expected$VYZ, which = "class") <- NULL
      expect_equal(DF %>% dplyr::mutate(matprods = matrixproduct_byname(V, 
          Y), VYZ = matrixproduct_byname(V, Y, Z)), DF_expected)
      M <- Y
      expect_equal(DF %>% dplyr::mutate(matprods = matrixproduct_byname(V, 
          M), VYZ = matrixproduct_byname(V, M, Z)), DF_expected)
  })
  where 20: eval(code, test_env)
  where 21: eval(code, test_env)
  where 22: 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 23: doTryCatch(return(expr), name, parentenv, handler)
  where 24: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 25: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 26: doTryCatch(return(expr), name, parentenv, handler)
  where 27: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 28: tryCatchList(expr, classes, parentenv, handlers)
  where 29: 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 30: test_code(NULL, exprs, env)
  where 31: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 32: force(code)
  where 33: doWithOneRestart(return(expr), restart)
  where 34: withOneRestart(expr, restarts[[1L]])
  where 35: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 36: 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 37: FUN(X[[i]], ...)
  where 38: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 39: force(code)
  where 40: doWithOneRestart(return(expr), restart)
  where 41: withOneRestart(expr, restarts[[1L]])
  where 42: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 43: 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 44: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 45: 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 46: 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 47: test_check("matsbyname")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (a, margin) 
  {
      if (class(a) == "numeric" & length(a) == 1) {
          return(1)
      }
      if (!length(margin) %in% c(1, 2)) {
          stop("margin should have length 1 or 2 in fractionize_byname")
      }
      if (length(margin) == 2 && all(margin %in% c(1, 2))) {
          stopifnot(nrow(a) == ncol(a))
          return(diag(nrow(a)) %>% setrownames_byname(rownames(a)) %>% 
              setcolnames_byname(colnames(a)) %>% setrowtype(rowtype(a)) %>% 
              setcoltype(coltype(a)))
      }
      if (length(margin) != 1 || !(margin %in% c(1, 2))) {
          stop(paste("Unknown margin", margin, "in identize_byname. margin should be 1, 2, or c(1,2)."))
      }
      if (margin == 1) {
          return(matrix(rep_len(1, nrow(a)), nrow = nrow(a), ncol = 1) %>% 
              setrownames_byname(rownames(a)) %>% setcolnames_byname(coltype(a)) %>% 
              setrowtype(rowtype(a)) %>% setcoltype(coltype(a)))
      }
      if (margin == 2) {
          return(matrix(rep_len(1, ncol(a)), nrow = 1, ncol = ncol(a)) %>% 
              setrownames_byname(rowtype(a)) %>% setcolnames_byname(colnames(a)) %>% 
              setrowtype(rowtype(a)) %>% setcoltype(coltype(a)))
      }
  }
  <bytecode: 0x565181e2c268>
  <environment: 0x565183481940>
   --- function search by body ---
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1