Running ‘testthat.R’ [5s/6s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(landscapemetrics)
  > library(raster)
  Loading required package: sp
  > 
  > test_check("landscapemetrics")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  landscapemetrics
   --- call from context --- 
  (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 
  1L, 1L, 1L, 3L, 3L, 3L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, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
   --- call from argument --- 
  if (class(landscape) != "matrix") {
      resolution <- raster::res(landscape)
      landscape <- raster::as.matrix(landscape)
  }
   --- R stacktrace ---
  where 1: (function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  })(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
  3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
  3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L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, 3L, 2L, 3L, 3L, 3L, 3L, 
  3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
  3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
  1))
  where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
  where 3: doTryCatch(return(expr), name, parentenv, handler)
  where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 5: tryCatchList(expr, classes, parentenv, handlers)
  where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
      error = function(e) {
          message("")
          stop(e)
      })
  where 7: FUN(X[[i]], ...)
  where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  })
  where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
      if (progress) {
          message("\r> Progress metrics: ", current_metric, "/", 
              number_metrics, appendLF = FALSE)
      }
      foo <- get(metrics_calc[[current_metric]], mode = "function")
      arguments <- names(formals(foo))
      tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
          error = function(e) {
              message("")
              stop(e)
          })
  }))
  where 10: FUN(X[[i]], ...)
  where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
      level = level, metric = metric, name = name, type = type, 
      what = what, directions = directions, count_boundary = count_boundary, 
      consider_boundary = consider_boundary, edge_depth = edge_depth, 
      classes_max = classes_max, neighbourhood = neighbourhood, 
      ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
      progress = progress)
  where 12: calculate_lsm.RasterLayer(landscape, what = "patch", verbose = FALSE)
  where 13 at testthat/test-calculate-lsm.R#5: calculate_lsm(landscape, what = "patch", verbose = FALSE)
  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(desc, code, env = parent.frame())
  where 25 at testthat/test-calculate-lsm.R#3: test_that("calculate_lsm can calculate patch metrics", {
      patch_metrics <- calculate_lsm(landscape, what = "patch", 
          verbose = FALSE)
      expect_is(patch_metrics, "tbl_df")
      expect_true(all(patch_metrics$level == "patch"))
      expect_true(ncol(patch_metrics) > 0)
  })
  where 26: eval(code, test_env)
  where 27: eval(code, test_env)
  where 28: 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 29: doTryCatch(return(expr), name, parentenv, handler)
  where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 31: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 32: doTryCatch(return(expr), name, parentenv, handler)
  where 33: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 34: tryCatchList(expr, classes, parentenv, handlers)
  where 35: 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 36: test_code(NULL, exprs, env)
  where 37: source_file(path, new.env(parent = env), chdir = TRUE, 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 = 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 43: FUN(X[[i]], ...)
  where 44: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 45: force(code)
  where 46: doWithOneRestart(return(expr), restart)
  where 47: withOneRestart(expr, restarts[[1L]])
  where 48: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 49: 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 50: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 51: 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 52: 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 53: test_check("landscapemetrics")
  
   --- value of length: 2 type: logical ---
  [1] FALSE  TRUE
   --- function from context --- 
  function (landscape, directions, resolution = NULL) 
  {
      if (class(landscape) != "matrix") {
          resolution <- raster::res(landscape)
          landscape <- raster::as.matrix(landscape)
      }
      factor_ha <- prod(resolution)/10000
      classes <- get_unique_values(landscape)[[1]]
      area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
          landscape_labeled <- get_patches(landscape, class = patches_class, 
              directions = directions, return_raster = FALSE)[[1]]
          area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
              factor_ha
          tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
      }))
      tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
          id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
          value = as.double(area_patch$value))
  }
  <bytecode: 0x555c0aecd0a0>
  <environment: namespace:landscapemetrics>
   --- function search by body ---
  Function lsm_p_area_calc in namespace landscapemetrics has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1