Running 'testthat.R' [5s/6s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library(testthat)
  > library(ModelMetrics)
  
  Attaching package: 'ModelMetrics'
  
  The following object is masked from 'package:base':
  
      kappa
  
  > 
  > test_check("ModelMetrics")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  ModelMetrics
   --- call from context --- 
  mlogLoss(y, xm)
   --- call from argument --- 
  if (class(predicted) %in% c("data.frame")) {
      predicted = as.matrix(predicted)
  }
   --- R stacktrace ---
  where 1 at testthat/test_logloss.R#13: mlogLoss(y, xm)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 12: test_code(desc, code, env = parent.frame())
  where 13 at testthat/test_logloss.R#4: test_that("mlogLoss character/factor actual", {
      Levs = 8
      Size = 100
      y = sample(1:Levs, Size, replace = TRUE)
      xm = matrix(runif(Levs * Size), ncol = Levs)
      xm = xm/rowSums(xm)
      m1 <- mlogLoss(y, xm)
      m2 <- mlogLoss(as.character(y), xm)
      m3 <- mlogLoss(as.factor(y), xm)
      expect_true(m1 == m2)
      expect_true(m1 == m3)
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 24: test_code(NULL, exprs, env)
  where 25: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 26: force(code)
  where 27: doWithOneRestart(return(expr), restart)
  where 28: withOneRestart(expr, restarts[[1L]])
  where 29: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 30: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 31: FUN(X[[i]], ...)
  where 32: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 33: force(code)
  where 34: doWithOneRestart(return(expr), restart)
  where 35: withOneRestart(expr, restarts[[1L]])
  where 36: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 37: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 38: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 39: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 40: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 41: test_check("ModelMetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (actual, predicted) 
  {
      if (class(actual) %in% c("factor", "character")) {
          actual = as.numeric(as.factor(actual))
      }
      if (class(predicted) %in% c("data.frame")) {
          predicted = as.matrix(predicted)
      }
      eps <- 1e-15
      predicted = pmax(pmin(predicted, 1 - eps), eps)
      mlogLoss_(actual, predicted)
  }
  <bytecode: 0x4237ba0>
  <environment: namespace:ModelMetrics>
   --- function search by body ---
  Function mlogLoss in namespace ModelMetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Error: mlogLoss character/factor actual (@test_logloss.R#13)  ------------
  the condition has length > 1
  Backtrace:
   1. ModelMetrics::mlogLoss(y, xm)
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  ModelMetrics
   --- call from context --- 
  mlogLoss(y, xm)
   --- call from argument --- 
  if (class(predicted) %in% c("data.frame")) {
      predicted = as.matrix(predicted)
  }
   --- R stacktrace ---
  where 1: mlogLoss(y, xm)
  where 2: eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
  where 3: withVisible(code)
  where 4: withCallingHandlers(withVisible(code), warning = handle_warning, 
      message = handle_message)
  where 5: force(code)
  where 6: withr::with_output_sink(temp, withCallingHandlers(withVisible(code), 
      warning = handle_warning, message = handle_message))
  where 7: .capture(act$val <- eval_bare(quo_get_expr(.quo), quo_get_env(.quo)), 
      ...)
  where 8: quasi_capture(enquo(object), NULL, evaluate_promise)
  where 9 at testthat/test_logloss.R#33: expect_silent(res1 <- mlogLoss(y, xm))
  where 10: eval(code, test_env)
  where 11: eval(code, test_env)
  where 12: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 13: doTryCatch(return(expr), name, parentenv, handler)
  where 14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 15: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 16: doTryCatch(return(expr), name, parentenv, handler)
  where 17: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 18: tryCatchList(expr, classes, parentenv, handlers)
  where 19: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 20: test_code(desc, code, env = parent.frame())
  where 21 at testthat/test_logloss.R#23: test_that("mlogLoss different classes", {
      Levs = 8
      Size = 100
      y = sample(1:Levs, Size, replace = TRUE)
      xm = matrix(runif(Levs * Size), ncol = Levs)
      xm = xm/rowSums(xm)
      expect_silent(res1 <- mlogLoss(y, xm))
      expect_true(!is.nan(res1))
      expect_silent(res2 <- mlogLoss(y, as.data.frame(xm)))
      expect_true(res1 == res2)
      expect_true(all(res1 == res2))
      expect_silent(res3 <- mlogLoss(as.character(y), as.data.frame(xm)))
      expect_true(res1 == res3)
      expect_true(all(res1 == res3))
      expect_silent(res4 <- mlogLoss(as.factor(y), as.data.frame(xm)))
      expect_true(res1 == res4)
      expect_true(all(res1 == res4))
      eps <- 1e-15
      classes <- LETTERS[1:3]
      test_dat1 <- data.frame(obs = c("A", "A", "A", "B", "B", 
          "C"), pred = c("A", "A", "A", "B", "B", "C"), A = c(1, 
          0.8, 0.51, 0.1, 0.2, 0.3), B = c(0, 0.05, 0.29, 0.8, 
          0.6, 0.3), C = c(0, 0.15, 0.2, 0.1, 0.2, 0.4))
      expected1 <- log(1 - eps) + log(0.8) + log(0.51) + log(0.8) + 
          log(0.6) + log(0.4)
      expected1 <- -expected1/nrow(test_dat1)
      result1 <- mlogLoss(test_dat1$obs, test_dat1[, 3:5])
      expect_equal(result1, expected1)
  })
  where 22: eval(code, test_env)
  where 23: eval(code, test_env)
  where 24: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 25: doTryCatch(return(expr), name, parentenv, handler)
  where 26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 27: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 28: doTryCatch(return(expr), name, parentenv, handler)
  where 29: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 30: tryCatchList(expr, classes, parentenv, handlers)
  where 31: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 32: test_code(NULL, exprs, env)
  where 33: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 34: force(code)
  where 35: doWithOneRestart(return(expr), restart)
  where 36: withOneRestart(expr, restarts[[1L]])
  where 37: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 38: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 39: FUN(X[[i]], ...)
  where 40: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 41: force(code)
  where 42: doWithOneRestart(return(expr), restart)
  where 43: withOneRestart(expr, restarts[[1L]])
  where 44: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 45: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 46: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 47: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 48: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 49: test_check("ModelMetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (actual, predicted) 
  {
      if (class(actual) %in% c("factor", "character")) {
          actual = as.numeric(as.factor(actual))
      }
      if (class(predicted) %in% c("data.frame")) {
          predicted = as.matrix(predicted)
      }
      eps <- 1e-15
      predicted = pmax(pmin(predicted, 1 - eps), eps)
      mlogLoss_(actual, predicted)
  }
  <bytecode: 0x4237ba0>
  <environment: namespace:ModelMetrics>
   --- function search by body ---
  Function mlogLoss in namespace ModelMetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 2. Error: mlogLoss different classes (@test_logloss.R#33)  ------------------
  the condition has length > 1
  Backtrace:
   1. testthat::expect_silent(res1 <- mlogLoss(y, xm))
   9. ModelMetrics::mlogLoss(y, xm)
  
  == testthat results  ===========================================================
  [ OK: 59 | SKIPPED: 1 | WARNINGS: 0 | FAILED: 2 ]
  1. Error: mlogLoss character/factor actual (@test_logloss.R#13) 
  2. Error: mlogLoss different classes (@test_logloss.R#33) 
  
  Error: testthat unit tests failed
  Execution halted