Running ‘testthat.R’ [6s/9s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(mize)
  > 
  > test_check("mize")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  mize
   --- call from context --- 
  callback(opt, stage, sub_stage, par, fg, iter, ...)
   --- call from argument --- 
  if (class(chol_result) == "try-error") {
      rm <- NULL
  }
   --- R stacktrace ---
  where 1: callback(opt, stage, sub_stage, par, fg, iter, ...)
  where 2: handler(opt, par, fg, iter, ...)
  where 3: life_cycle_hook(phase, "during", opt, par, fg, iter)
  where 4: callback(opt, stage, par, fg, iter, ...)
  where 5: handler(opt, par, fg, iter, ...)
  where 6: life_cycle_hook(stage$type, "during", opt, par, fg, iter)
  where 7: mize_step(opt, par, fg)
  where 8 at testthat/test_newton.R#12: opt_loop(opt, rb0, rosenbrock_fg, 20, store_progress = TRUE, 
      verbose = FALSE, grad_tol = 1e-05)
  where 9: eval(code, test_env)
  where 10: eval(code, test_env)
  where 11: 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 12: doTryCatch(return(expr), name, parentenv, handler)
  where 13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 14: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 15: doTryCatch(return(expr), name, parentenv, handler)
  where 16: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 17: tryCatchList(expr, classes, parentenv, handlers)
  where 18: 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 19: test_code(desc, code, env = parent.frame())
  where 20 at testthat/test_newton.R#3: test_that("Newton with basic backtracking works ok", {
      opt <- make_opt(make_stages(gradient_stage(direction = newton_direction(), 
          step_size = backtracking(rho = 0.5, c1 = 1e-04)), verbose = FALSE))
      opt$count_res_fg <- FALSE
      res <- opt_loop(opt, rb0, rosenbrock_fg, 20, store_progress = TRUE, 
          verbose = FALSE, grad_tol = 1e-05)
      nfs <- c(0, 2, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 
          22, 23, 24, 25, 26, 27, 28)
      ngs <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
          15, 16, 17, 18, 19, 20)
      fs <- c(24.2, 4.73, 4.09, 3.23, 3.21, 1.94, 1.6, 1.18, 0.922, 
          0.597, 0.453, 0.281, 0.211, 0.089, 0.0515, 0.02, 0.00717, 
          0.00107, 7.78e-05, 2.82e-07, 8.42e-12)
      g2ns <- c(232.87, 4.64, 28.55, 11.57, 30.33, 3.6, 9.25, 4.92, 
          8.66, 1.78, 5.88, 2.18, 9.4, 0.492, 3.92, 1.24, 2.53, 
          0.238, 0.348, 0.00387, 0.0001187)
      steps <- c(0, 0.381, 0.619, 0.268, 0.58, 0.0793, 0.233, 0.146, 
          0.208, 0.112, 0.165, 0.143, 0.248, 0.107, 0.174, 0.125, 
          0.16, 0.0608, 0.0621, 0.00801, 0.00117)
      alphas <- c(0, 1, 0.125, 1, 1, 1, 0.25, 1, 1, 1, 0.5, 1, 
          1, 1, 0.5, 1, 1, 1, 1, 1, 1)
      par <- c(1, 1)
      expect_equal(res$progress$nf, nfs)
      expect_equal(res$progress$ng, ngs)
      expect_equal(res$progress$f, fs, tol = 0.001)
      expect_equal(res$progress$g2n, g2ns, tol = 0.001)
      expect_equal(res$progress$step, steps, tol = 0.001)
      expect_equal(res$progress$alpha, alphas, tol = 0.001)
      expect_equal(res$par, par, tol = 0.001)
  })
  where 21: eval(code, test_env)
  where 22: eval(code, test_env)
  where 23: 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 24: doTryCatch(return(expr), name, parentenv, handler)
  where 25: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 26: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 27: doTryCatch(return(expr), name, parentenv, handler)
  where 28: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 29: tryCatchList(expr, classes, parentenv, handlers)
  where 30: 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 31: test_code(NULL, exprs, env)
  where 32: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 38: FUN(X[[i]], ...)
  where 39: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 40: force(code)
  where 41: doWithOneRestart(return(expr), restart)
  where 42: withOneRestart(expr, restarts[[1L]])
  where 43: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 44: 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 45: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 46: 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 47: 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 48: test_check("mize")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (opt, stage, sub_stage, par, fg, iter) 
  {
      gm <- opt$cache$gr_curr
      if (!is.null(fg$hs)) {
          bm <- fg$hs(par)
          if (methods::is(bm, "matrix")) {
              if (try_safe_chol) {
                  rm <- safe_chol(bm)
              }
              else {
                  chol_result <- try({
                    rm <- chol(bm)
                  }, silent = TRUE)
                  if (class(chol_result) == "try-error") {
                    rm <- NULL
                  }
              }
              if (is.null(rm)) {
                  pm <- -gm
              }
              else {
                  pm <- hessian_solve(rm, gm)
              }
          }
          else {
              pm <- -(1/bm) * gm
          }
      }
      else if (!is.null(fg$hi)) {
          hm <- fg$hs(par)
          if (methods::is(hm, "matrix")) {
              pm <- -hm %*% gm
          }
          else {
              pm <- -hm * gm
          }
      }
      else {
          stop("No hi or hs function available for Hessian information")
      }
      descent <- dot(gm, pm)
      if (descent >= 0) {
          pm <- -gm
      }
      sub_stage$value <- pm
      list(sub_stage = sub_stage)
  }
  <bytecode: 0x5567608cc418>
  <environment: 0x5567618c9078>
  attr(,"event")
  [1] "during direction"
  attr(,"name")
  [1] "handler"
   --- function search by body ---
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1